我的命令如下
cmd1 | cmd2 | cmd3
在将它们传递给另一个进程之前,我需要查看命令输出。 我该怎么做?
如果我用
cmd1 > file1 | cmd2 | cmd3
我想我必须在 cmd2 的过程中管理从文件中读取,但我想要的是让标准输出传递给不同的命令并查看传递的是什么。
最佳答案
如前所述,您可以使用 tee
和 /dev/tty
作为您执行的命令之间的参数:
ls -l | tee /dev/tty | grep one_file -A2 | tee /dev/tty | grep something_else
关于Linux : how to redirect to a file and to another process,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35011542/