在发球断管与工艺substituion [英] Broken pipe in tee with process substituion

查看:101
本文介绍了在发球断管与工艺substituion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是发现了关于使用&GT工艺替代;()和我超级兴奋,但是当我试了一下,它并不总是工作。例如

I just found out about process substitution using >() and am super excited about it, however when I tried it, it doesn't always work. e.g.

本作品:

cat /usr/share/dict/words |tee >(tail -1) > /dev/null
ZZZ

这给出了一个破裂的管道错误:

And this gives a broken pipe error:

cat /usr/share/dict/words |tee >(head -1) > /dev/null
1080
tee: /dev/fd/63: Broken pipe

任何想法,为什么?
谢谢!

Any idea why? Thanks!

更新:这是RHEL 4和RHEL 6.2

Update: This is on RHEL 4 and RHEL 6.2

推荐答案

下面就是为什么你得到头错误的解释,但不与尾:

here's an explanation of why you get the error with head but not with tail:

头-1只需要读取其输入的一行。那么它会退出并三通继续其输出送入...

head -1 only has to read one line of its input. then it will exit and the tee continues feeding its output into...

尾-1,另一方面有阅读完整的输入,以完成其工作,所以发球完成之前不会终止管道。

tail -1 on the other hand has to read the complete input in order to complete its job, so it will never terminate the pipe before tee is finished.

您可以安全地忽略中断管道消息和许多程序停止报告这样的错误。我的机器上我没有看到它。

you can safely ignore the broken pipe message and many programs stopped reporting such errors. on my machine I don't see it.

这篇关于在发球断管与工艺substituion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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