Why does pipeline work this way?

Conor P. Cahill cpcahil at virtech.uucp
Sun Dec 17 00:34:16 AEST 1989


In article <10064 at saturn.ucsc.edu>, ray at saturn.ucsc.edu (Ray Swartz) writes:
> Yet, when I run grep by itself, the output comes out to the tty as soon
>  as grep finds a line.  Why is it that when grep prints to a terminal
> the output appears unbuffered and when it is going into a pipe, it
> appears buffered?

Grep writes it's matches to stdout which is buffered by line on output
to a terminal and buffered by data block on any other output medium, including
pipes.

If you really want this functionality, get the gnu grep sources and add
a parameter to stop looking after the first match (i.e. only show the
first matching record).  Or you could make it reall inefficient and turn
off all buffering, but I don't recommend this.


-- 
+-----------------------------------------------------------------------+
| Conor P. Cahill     uunet!virtech!cpcahil      	703-430-9247	!
| Virtual Technologies Inc.,    P. O. Box 876,   Sterling, VA 22170     |
+-----------------------------------------------------------------------+



More information about the Comp.unix.questions mailing list