command substitution and the pipe
am 27.10.2007 01:22:05 von garyjefferson123suppose I have prepared a command* such as:
~$ cmd="echo \"something1 : something2\" | awk '{print \$1, \$2}'"
and now I want to execute it as if it had been typed at the bash
prompt:
~$ $cmd
which produces:
"something1 : something2" | awk '{print $1, $2}'
I can't see how to get backticks or $() to work for me here, either.
Is there some trick to use to get command substitution to evaluation
the pipe and do what I'm looking for here (besides echoing the command
to a file and then execing it inside a bash prompt)?
Thanks,
Gary
*nevermind that there are other ways to accomplish this without the
pipe -- the sufficiently more complicated example that I'm trying to
solve *cannot* be done without the pipe. The question I'm asking here
is not "how do I do this without the pipe?" it is "how do I get bash
command substitution to work with the pipe in the constructed command?"