正常情况下当运行命令: command1 | command2 时,只能把command1标准输出传入command2 输入,即只能将标准流传入管道,但有时我们需要将错误流传入管道,就比较麻烦了。有以下解决方案:
-
command1 2>&1 | command2 ,这样可以把错误流重定向到标准输入流,然后在传入管道。这样的问题是标准流和错误流混在一起了,这可能不是我们所需要的。
-
在bash、tcsh中直接支持将错误流传入管道,即 command1 |& command2,这样方法最方便,但不是所有shell都能够支持的。
-
先把错误流文件保存到临时文件中,在读取,然后重定向,即 command1 2>tmpfile && cat tmpfile | command2,这种方式健壮性比较好,但同时效率肯定比较低的。
当然或许有其他更好的方式,目前仅想到这几种方式。
2025年1月11日 02:49
I prefer merely excellent resources - you will see these people in: Kissimmee Exterminator
2025年1月15日 20:01
This is exciting, nevertheless it is vital for you to visit this specific url: Tampa Exterminator
2025年3月10日 17:33
I wrote about a similar issue, I give you the link to my site. singapore printing
2025年3月11日 20:46
This is helpful, nonetheless it can be crucial so that you can check out the following website: production
2025年3月18日 02:22
Your blogs further more each else volume is so entertaining further serviceable It appoints me befall retreat encore. I will instantly grab your rss feed to stay informed of any updates. One Marina Gardens
2025年3月20日 20:58
On that website page, you'll see your description, why not read through this. public accounting company
2025年3月22日 18:15
This is very appealing, however , it is very important that will mouse click on the connection: full body massage