Linux : how to redirect to a file and to another process

标签 linux io pipe

我的命令如下

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/

相关文章:

java - 输入流/读取器是否总是意味着关闭?

c - 在 C : 中限制控制台输入长度

bash - 为什么在 bash 中使用管道命令与 && 连接命令时得到不同的结果?

mysql - Fedora 和安装 Ruby,使用 gem 系统,将 MySQL 连接到 Ruby

c++ - 库无法正确导出功能

java.lang.OutOfMemory错误: Java heap space Exception while Parsing of Large file using ANTLR

c - `write()` 和 `read()` 无法正常工作

c++ - 提升进程 running() 和 exit_code() 线程安全

linux - gradle 构建在 Linux 中不起作用

ruby-on-rails - 如何修复 Errno::EACCES: 权限被拒绝@ dir_s_mkdir -