庆典重定向标准输出/标准错误,以两地? [英] Redirecting bash stdout/stderr to two places?

查看:99
本文介绍了庆典重定向标准输出/标准错误,以两地?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这一次的被窃听,现在我一会儿。是否有可能重定向标准输出标准错误到终端输出的的一个程序?

This one's been bugging me for a while now. Is it possible to redirect stdout and stderr to both the terminal output and to a program?

我知道这是可能的输出重定向到一个文件和标准输出 T恤 ,但我想它去到一个程序(我的编辑[TextMate的]),以及到终端输出......当然这是可能的(我知道它有可能与zsh的...)

I understand it's possible to redirect the outputs to a file and to stdout with tee, but I want it to go to a program (my editor [TextMate]) as well as to the terminal output… surely this is possible (I know its possible with zsh…)

推荐答案

您可以使用命名管道,其目的正是为您所描述的情况。

You can use a named pipe, which is intended for exactly the situation you describe.

mkfifo some_pipe
command_that_writes_to_stdout | tee some_pipe \
  & command_that_reads_from_stdin < some_pipe
rm some_pipe

或者,在击:

command_that_writes_to_stdout | tee >(command_that_reads_from_stdin)

这篇关于庆典重定向标准输出/标准错误,以两地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆