[TriLUG] bash question

Jeremy Portzer jeremyp at pobox.com
Wed Oct 17 22:28:57 EDT 2007


Joseph Mack NA3T wrote:
> On Thu, 18 Oct 2007, Jeremy Portzer wrote:
> 
>> You can also use "eval"
>>
>> CMDA="ls |"
>> CMDB="wc -l"
>> eval "$CMDA$CMDB"
> 
> hmm. I see.
> 
> I had tried
> 
> eval `$CMDA$CMDB`

Well, you're using two different shell constructs together here.  The 
backtick operator means "run whatever is inside the backticks as a 
command and use its output as a command argument."  Then, the eval 
statement, as discussed, attempts to run its arguments as a shell 
command.  So, supposing the output of "ls|wc -l" is 34, then what you're 
doing in the above is asking bash to run the command "34".  This 
probably isn't a valid command.

The "eval backick" thing might have a valid use, since obviously the 
output of a command *could* be a valid command to use for eval, but I'd 
be careful.

--Jeremy



More information about the TriLUG mailing list