2 ms·
This is the first thing I noticed too. >how does cat know to stop when head is finished I'm no expert on Unix, so correct me if I'm wrong, but surely this lin
by happytoexplain 7y ago
This is the first thing I noticed too.
>how does cat know to stop when head is finished
I'm no expert on Unix, so correct me if I'm wrong, but surely this line of reasoning is misleading because pipes create a unidirectional data flow, so `cat` can not know anything about `head`. It does not "stop" - it passes the whole text along just as it did without the pipe. As you said, the delay comes in printing to the console, not in the `cat` command.
- cperciva 7y agoPipes aren't completely unidirectional. You get one bit of information flowing back: Whether the read end of the pipe is still open.
- kyuudou 7y agoThis is a great example of Useless Use of cat and why it is bad - the full text is indeed sent through the pipe simply for head to chop n initial lines. I've actually had "developers" go "but, readability". Yea ok.