Shell Sh Script: Running complex commands stored in variable

by rajesh 2013-11-24 13:31:00

A command with pipe symabol or double quotes or single quote wtch may not work fine inside a shell script if it is stored in a variable.

In normal case, we would store the command in a variable name and run it using $ as

CMD=’ls -l’
$CMD


But when it does not work that way, try using eval

CMD=’ps -elf|grep vnc’
eval $CMD
860
like
0
dislike
0
mail
flag

You must LOGIN to add comments