将bash stdout / stderr重定向到两个地方?(Redirecting bash stdout/stderr to two places?)
这个人一直在窃听我一段时间。 是否有可能将stdout和stderr重定向到终端输出和程序?
我知道有可能将输出重定向到一个文件并使用tee进行stdout ,但我希望它能够进入一个程序(我的编辑器[TextMate])以及终端输出...当然这是可能的(我知道它是可能的用zsh ...)
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?
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…)
最满意答案
您可以使用命名管道,该管道专门用于您描述的情况。
mkfifo some_pipe command_that_writes_to_stdout | tee some_pipe \ & command_that_reads_from_stdin < some_pipe rm some_pipe或者,在Bash中:
command_that_writes_to_stdout | tee >(command_that_reads_from_stdin)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_pipeOr, in Bash:
command_that_writes_to_stdout | tee >(command_that_reads_from_stdin)更多推荐
发布评论