So if I put some simple commands into a variable, and then call that variable at the beginning of the line, it actually uses those commands. For example:
yes@no:~$ nnn="ls -l Super"
yes@no:~$ $nnn
-rw-rw-rw- 1 yes yes 6 May 29 19:46 Super
But if I try it with anything that has any special characters, or if I try with something like case
or if
, it doesn't work:
yes@no:~$ nnn="ls -l|grep Super"
yes@no:~$ $nnn
ls: invalid option -- '\'
Try 'ls --help' for more information.
Or:
yes@no:~$ duper="if [[ ${ar} -eq 2 ]]; then echo yes; else echo no; fi"
yes@no:~$ "$duper"
if [[ -eq 2 ]]; then echo yes; else echo no; fi: command not found
Obviously there's something deeper here that I do not understand.