How does piping to head work?
Let's say I have a command which throws n lines of output. I'm only interested in seeing the 1st 10 lines so I pipe it to head.
I'm trying to understand how piping works. Does command finish executing completely before handing off to head which displays only the first 10 lines?
Does the time taken to execute command | head depend on what the value of n is? If yes, is it possible to make it independent somehow? For eg. having some sort of feedback between head and the command by having the RHS of the pipe kill the LHS?
NOTE that I'm interested in this only as an exercise and to investigate if it's possible or not. If it's practical and useful or not is a completely different issue.
Posted Feb 22, 2016, 5:37 AM UTC
3916