非常奇怪的重定向 stdout 和 stderr 问题有人可以解释一下吗?
我有两个调用产生非常不同的输出:
调用一:
dmake -m _makefile_.m 1>> _results.out 2>> _results.out
调用二:
dmake -m _makefile_.m >2&1 >_results.out
dmake 进行某种编译,第一个调用正确内联编译错误,而第二个调用将所有编译错误放在顶部。我一直认为这两者是等效的。这两个调用到底有什么区别?这是因为缓冲吗?
I have two calls that produce very different output:
Call one:
dmake -m _makefile_.m 1>> _results.out 2>> _results.out
Call two:
dmake -m _makefile_.m >2&1 >_results.out
dmake does a compile of sorts and the first call correctly inlines compile errors whereas the second one puts all the compile errors at the top. I was always of the opinion that both of these were equivalent. What exactly are the differences between these two calls? Is this because of buffering?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
>2&1
语法不正确;它将把 dmake 命令的输出重定向到名为 2 的文件(在后台运行),然后尝试运行名为 1 的命令其输出重定向到_results.out
。您需要:
如果要附加到文件,请将
>
更改为>>
。我不确定这是否会按照您想要的方式分散 stdout 和 stderr 。
>2&1
is not the right syntax; it will redirect the output of thedmake
command to a file called2
(running it in background), then attempt to run a command called1
with its output redirected to_results.out
.You want:
Change
>
to>>
if you want to append to the file.I'm not 100% sure whether this will intersperse stdout and stderr the way you want.