Quit on match

Tom Poage poage at sunny.ucdavis.edu
Tue Dec 19 10:31:34 AEST 1989


In article <1989Dec16.133416.3855 at virtech.uucp> cpcahil at 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 at sunny.ucdavis.edu  {...,ucbvax,uunet}!ucdavis!sunny!poage



More information about the Comp.unix.questions mailing list