Tuesday, 13 August 2013

Evaluating variables in a string

Evaluating variables in a string

The last line in this script won't work as I expect:
myfile="afile.txt"
mycmd='cat $myfile'
eval $mycmd
echo eval $mycmd
Here echo prints 'eval cat $myfile'. How can I print 'eval cat afile.txt'?

No comments:

Post a Comment