[NTLUG:Discuss] in a world where grep doesn't have the -m (match) option..

Chris Cox cjcox at acm.org
Tue Mar 25 16:22:06 CDT 2008


Richard wrote:
> ..how would one go about stopping a grep after the first match? I'm 
> sitting here trying to figure out how to do something in a while loop 
> but I am missing something.
> 

Somewhat portable (doesn't exactly stop after first match, but
close depending on size)...

grep 'whatever' file | head -1
(that's a minus one)



More information about the Discuss mailing list