Wednesday, June 19, 2013

How to set a BASH variable equal to the output from a command?

In addition to the backticks, you can use $(), which I find easier to read, and allows for nesting.
OUTPUT=$(ls -1)
echo $OUTPUT
 
 
You can use eval to execute a string:
eval $illcommando
 

No comments:

Post a Comment