Tuesday, September 11, 2007

HOWTO: search unix's $LD_LIBRARY_PATH

In figuring out how to search $LD_LIBRARY_PATH for (hopefully not multiply) installed versions of libraries, I found that $LD_LIBRARY_PATH, being colon-delimited, was not suitable argument for the unix `find` command.

Thus, an 'on-the-fly' edit to replace the colons with spaces is needed, consing up a suitable arg to find.

I had never used the string substitution modifer to bash's parameter expansion. Now I do.

For example:

>find ${LD_LIBRARY_PATH//:/ } -maxdepth 1 -name libreadline.* -print

Which prompts me to write the following bash function:

function llpfind {
# EXAMPLE: llpfind -name libreadline.*
find ${LD_LIBRARY_PATH//:/ } -maxdepth 1 $@ -print