Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.questions Subject: Re: Why does pipeline work this way? Summary: because stdout output is buffered Keywords: pipeline, grep | cat Message-ID: <1989Dec16.133416.3855@virtech.uucp> Date: 16 Dec 89 13:34:16 GMT References: <10064@saturn.ucsc.edu> Organization: Virtual Technologies Inc. Lines: 21 In article <10064@saturn.ucsc.edu>, ray@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 | +-----------------------------------------------------------------------+