我有一个动态生成 bash 命令的文件“commands.php”。例如,一行是:
# - commands.php
ssh me@123.123.123.123 echo "text" > file; reboot;
Run Code Online (Sandbox Code Playgroud)
我如何使用 的输出xargs
来执行这些命令... eval,也许?
cat commands.php | xargs -L 1 -I {} 'eval "$({})"';
Run Code Online (Sandbox Code Playgroud)
想了个办法:
cat commands.php | xargs -L 1 -I {} sh -c "{}"
Run Code Online (Sandbox Code Playgroud)
在 shell 外运行每个命令......足够简单!
归档时间: |
|
查看次数: |
4550 次 |
最近记录: |