Broken pipe in tee with technological replacement

I just found out about replacing a process with >() and am very worried about it, however, when I tried it, it does not always work. eg

It works:

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

And this gives a pipe break error:

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

Any idea why? Thanks!

Update: this is on RHEL 4 and RHEL 6.2

+4
bash shell
source share
1 answer

here is an explanation of why you get the error with the head, but not with the tail:

head -1 should read only one line of its input. then he will come out, and the tee will continue to give his way out to ...

tail -1, on the other hand, must read the full input to complete its task, so that it will never shut down the pipe before tee completes.

you can safely ignore a pipe break message, and many programs stop reporting errors. I donโ€™t see it on my car.

+1
source share

All Articles