【发布时间】:2011-03-29 00:51:43
【问题描述】:
我尝试使用管道运行命令。
基本:
single="ls -l"
$single
按预期工作
管道:
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
...毫不奇怪
bash < $multi
$multi: ambiguous redirect
下次尝试
bash $multi
/bin/ls: /bin/ls: cannot execute binary file
只有
echo $multi > tmp.sh
bash tmp.sh
工作。
有没有办法在不创建执行脚本的情况下执行更复杂的命令?
【问题讨论】:
标签: linux bash shell command-line