01-27-07 12:22 PM
I'm confused with the result of the following script:
cmd="echo abc | grep abc"
echo $($cmd)
it's output in my linux box is :
abc | grep abc
It seems that the command substitution treats the cmd's value as one
command unit(not two commands combined with '|') with arguments
separated by whitespace. Why? If it is because the quoting, I think it
should treats the whole string as a command name, just as :
echo $("echo abc | grep abc")
Can somebody explain it? Thanks.
[ Post a follow-up to this message ]
|