管仅通过过滤器标准错误 [英] pipe only stderr through a filter
本文介绍了管仅通过过滤器标准错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
通过一个过滤器有没有什么办法,在bash,管道与标准错误统一标准输出之前?也就是说,我想
标准输出---------------- \\
| ----->终端/文件/什么
标准错误 - [滤镜] - /
而不是
标准输出---- \\
| ---- [过滤器] --->终端/文件/什么
标准错误---- /
解决方案
下面是一个例子,的如何交换文件在bash 描述符。 a.out的输出是下面的,没有STDXXX:'preFIX
STDERR:stderr输出
STDOUT:更经常的./a.out 3 GT;&放大器; 1 1>和2 2 - ;和3 3 GT;&放大器; - | SED的/ E / E / G'
更经常的
stderr输出
从上面的链接引用:
- 先保存为标准输出和3(安培; 1被骗3)
- 下发标准输出到标准错误(安培;二是被骗1)
- 发送到标准错误和3(标准输出)(安培;三是被骗2)
- 关闭和3(安培; - 是被骗3)
块引用>Is there any way, in bash, to pipe stderr through a filter before unifying it with stdout? That is, I want
stdout ----------------\ |-----> terminal/file/whatever stderr -- [ filter ] --/
rather than
stdout ----\ |----[ filter ]---> terminal/file/whatever stderr ----/
解决方案Here's an example, modeled after how to swap file descriptors in bash . The output of a.out is the following, without the 'STDXXX: ' prefix.
STDERR: stderr output STDOUT: more regular ./a.out 3>&1 1>&2 2>&3 3>&- | sed 's/e/E/g' more regular stdErr output
Quoting from the above link:
- First save stdout as &3 (&1 is duped into 3)
- Next send stdout to stderr (&2 is duped into 1)
- Send stderr to &3 (stdout) (&3 is duped into 2)
- close &3 (&- is duped into 3)
这篇关于管仅通过过滤器标准错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文