8
如何将命令存储在Shell脚本的变量中?
我想将要在以后使用的命令存储在变量中(不是命令的输出,而是命令本身) 我有一个简单的脚本,如下所示: command="ls"; echo "Command: $command"; #Output is: Command: ls b=`$command`; echo $b; #Output is: public_html REV test... (command worked successfully) 但是,当我尝试更复杂的操作时,它会失败。例如,如果我做 command="ls | grep -c '^'"; 输出为: Command: ls | grep -c '^' ls: cannot access |: No such file or directory ls: cannot access grep: No such file …