[comp.unix.questions] Quit on match

poage@sunny.ucdavis.edu (Tom Poage) (12/19/89)

In article <1989Dec16.133416.3855@virtech.uucp> cpcahil@virtech.uucp (Conor P. Cahill) writes:
...
>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     |
>+-----------------------------------------------------------------------+

Alternatively, try

	sed -n '/pattern/{
	p
	q
	}' filename

The matching line is printed immediately since output is
flushed on close.  Tom.
-- 
Tom Poage, Clinical Engineering
Universiy of California, Davis, Medical Center, Sacramento, CA
poage@sunny.ucdavis.edu  {...,ucbvax,uunet}!ucdavis!sunny!poage