In previous aticle: If you’re cool enough to watch video in console?
Recently saw article on one LinedIn channel explaining Linux shell pipes and again saw the same mistake – 99% engineers doesn’t know how pipes actually works!
Absolutely sure you will be “not absolutely sure” how long that command sleep:
sleep 5 | sleep 5 | sleep 5 | sleep 5
You may “suspect” that it will be 20 seconds, but it’s not true.
It’s surprising people, that ALL commands in pipe running simultaneously! And command will sleep 5 secs.
You can check it with ps -ef | grep slee[p]
while sleep is running.
That’s the reason why you see intermediate result when grepping large file and not waiting for command to finish, in case of sequential run of commands in pipe.
Support Us, Contact Us
If you like this post, support us, download, try and give us feedback!