>       Just to clarify why this doesn't work:  you're setting
>       the value of $mp3Dir to "cat ~/mp3dir".  You have to use
>       backticks (``) to call execution.

Brandon is right about the reason, but ever since Bash 2.0 there's been a
more elegant (and preferred) way to populuate a variable with a value
resulting from the execution of a command.  A dollar sign immediately
prepended to a command-line enclosed by parentheses acts as a variable
whose value is the final result of the command-line.  So in this example,
the way to do it might be:

MP3DIR=$HOME/mp3dir
cd $(cat $MP3DIR)

The command-line in the parenthetical interpolation can be as complicated
as any you would enter on a shell command-line, including pipes,
redirections, variables, arithmetical expressions and even nested
command-line variable interpolations.  So let's say that Tack had a
directory ~/mp3z/ filled with files named things like "rock_mp3z":

MP3DIR=$HOME/mp3z
ROCK=$(cat $(ls $MP3DIR | grep "rock"))

Back-ticks are now deprecated in Bash.

E


_______________________________________________
Bits mailing list
[EMAIL PROTECTED]
http://www.sugoi.org/mailman/listinfo/bits

Reply via email to