我的命令如下
cmd1 | cmd2 | cmd3
我需要在将命令输出到另一个进程之前查看输出。 我怎么能这样做?
如果我使用
cmd1 > file1 | cmd2 | cmd3
我想我必须在cmd2的过程中管理从文件读取,但我想要的是传递标准输出抛出不同的命令并查看传递的内容。
答案 0 :(得分:2)
查看tee
命令。它可能就是你要找的东西。
例如:
cmd1 | tee file1 | cmd2 | cmd3
答案 1 :(得分:2)
如上所述,您可以在tee
之间使用/dev/tty
作为执行命令之间的参数:
ls -l | tee /dev/tty | grep one_file -A2 | tee /dev/tty | grep something_else
答案 2 :(得分:1)
您可以使用tee
命令:
tee - read from standard input and write to standard output and files
示例:
echo hi | tee 1.txt | cat -n | tee 2.txt | grep hi