I tried to run commands using pipes.
Basic:
single="ls -l"
$single
which works as expected
Pipes:
multi="ls -l | grep e"
$multi
ls: |: No such file or directory
ls: grep: No such file or directory
ls: e: No such file or directory
...no surprise
bash < $multi
$multi: ambiguous redirect
next try
bash $multi
/bin/ls: /bin/ls: cannot execute binary file
Only
echo $multi > tmp.sh
bash tmp.sh
worked.
Is there a way to execute more complex commands without creating a script for execution?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…