grep replacement
Brian Campbell
brianc at cognos.uucp
Wed Jun 8 00:17:57 AEST 1988
In article <4524 at vdsvax.steinmetz.ge.com> Bruce G. Barnett writes:
> There have been times when I wanted a grep that would print out the
> first occurrence and then stop.
In article <1036 at cfa.cfa.harvard.EDU> Bill Wyatt suggests:
> grep '(your_pattern_here)' | head -1
In article <4537 at vdsvax.steinmetz.ge.com> Bruce G. Barnett replies:
> There are times when I want the first occurrence of a pattern without
> reading the entire (i.e. HUGE) file.
If we're talking about finding subject lines in news articles:
head -20 file1 file2 ... | grep ^Subject:
> Or there are times when I want the first occurrence of a pattern from
> hundreds of files, but I don't want to see the pattern more than once.
In this case, the original suggestion seems appropriate:
grep pattern file1 file2 ... | head -1
--
Brian Campbell uucp: decvax!utzoo!dciem!nrcaer!cognos!brianc
Cognos Incorporated mail: POB 9707, 3755 Riverside Drive, Ottawa, K1G 3Z4
(613) 738-1440 fido: (613) 731-2945 300/1200/2400, sysop at 1:163/8
More information about the Comp.unix.questions
mailing list