在 eval 命令中使用 xargs 输入

d-_*_*_-b 3 bash xargs

我有一个动态生成 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)

d-_*_*_-b 9

想了个办法:

cat commands.php | xargs -L 1 -I {} sh -c "{}"
Run Code Online (Sandbox Code Playgroud)

在 shell 外运行每个命令......足够简单!