Re: Variable substitution in issuing bash commands?
am 29.09.2007 16:33:47 von Stephane CHAZELAS
2007-09-29, 07:15(-07), frolib@gmail.com:
[...]
> Hello. I's a bash newbie. If I want to compose a command containing a
> substituted variable in a script I do this
>
> echo "command $substituted_variable" | bash
>
> Is this the right way to do it? Thanks.
Yes (except that printf is prefered over echo as echo has a
number of issues when passed arbitrary arguments).
eval "command $substituted_variable"
is the same as above except that it's the current shell that is
interpreting the shell code.
--
Stéphane