dear lazy web ... (UNIX pipes)

Mark Overmeer mark at
Sat Apr 19 15:52:25 BST 2008

* Greg McCarroll (greg at [080419 14:40]:
> now today i wondered about,
>     process_that_generates_output | grep something | head
> wondering if when head had enough output to make it happy it would
> terminate and that would propogate to grep and the first process.
> and so i experimented timing the first process with and without head
> as the final pipe, and in a very unscientific test it came out with
> the same result.

The pipe is buffered in 4kB blocks by default.  Your process will
terminate if 'head' got its 4 kB from grep (or EOD).  Probably, grep
doesn't pass enough data through, such that the initial process has to
do all its work before head decides to quit and kill the pipe-line.


       Mark Overmeer MSc                                MARKOV Solutions
       Mark at                          solutions at         

More information about the mailing list