In The Unix Programming Environment by K & P, it is written that
” The programs in a pipeline actually run at the same time, not one after another.
This means that programs in a pipeline can be interactive;”
How can programs run at same time?
For ex: $ who | grep mary | wc -l
How grep mary will be executed until who is run or how wc -l will be executed until it
knows results of previous programs?
whowill output a line of data, whichgrepwill then receivestdout, whichwcwill then read and countwhomay also have been writing out more data forgrepetcEach program needs the results of the previous one, but it doesn’t need all of the results before it can start working, which is why pipelining is feasible.