linux - 使用一个命令的输出作为下一个命令的输入

标签 linux bash

所以我从命令行调用这个 PHP 脚本:

/usr/bin/php /var/www/bims/index.php "projects/output"

它的输出是:

file1 file2 file3

我想做的是获取此输出并提供给“rm”命令,但我认为我没有做对:

/usr/bin/php /var/www/bims/index.php "projects/output" | rm 

我的目标是删除 PHP 脚本输出的任何文件名。这样做的正确方法应该是什么?

谢谢!

最佳答案

/usr/bin/php /var/www/bims/index.php "projects/output" | xargs rm

关于linux - 使用一个命令的输出作为下一个命令的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2689537/

相关文章:

linux -/var/log/文件夹权限每天自动更改

regex - 如何验证正则表达式匹配的内容?

linux shell 查找、比较和删除文件

git - 如何要求确认 git reset --hard?

bash - while 循环出现意外的 bash 退出

python - 使用 Python 向远程进程发送信号

PHP:执行命令,然后继续?

bash - 如何调用 shellscript 语法检查器(通过/使用 syntastic 和病原体)?

python - 如何在 Python 脚本中运行 bash 命令

java - 从 Java 运行 linux 脚本