为了执行存储在变量中的命令eval
使用命令:
└──> a="echo -e 'a\nb' | wc -l"
└──> eval $a
2
但如何才能与它结合起来呢?timeout
命令?我尝试过以下操作,这给了我错误的输出:
└──> timeout 10 $a
'a
b' | wc -l
以下给了我错误:
└──> timeout 10 "$a"
timeout: failed to run command `echo -e \'a\\nb\' | wc -l': No such file or directory
└──> timeout 10 $(eval $a)
timeout: failed to run command `2': No such file or directory
└──> timeout 10 $(eval "$a")
timeout: failed to run command `2': No such file or directory
问题还可以是:我如何确定以下命令正确执行?
timeout 10 "$PROGRAM" "$OPT1" "$OPT2" ...
Simple:
a="echo -e 'a\nb' | wc -l"
eval timeout 10 $a
Output:
2
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)