grep replacement
Joe Pruett
joey at tessi.UUCP
Tue May 31 04:37:09 AEST 1988
>
>> There have been times when I wanted a grep that would print out the
>> first occurrence and then stop.
>
>grep '(your_pattern_here)' | head -1
This works, but is quite slow if the input to grep is large. A hack
I've made to egrep is a switch of the form -<number>. This causes only
the first <number> matches to be printed, and then the next file is
searched. This is great for:
egrep -1 ^Subject *
in a news directory to get a list of Subject lines.
More information about the Comp.unix.wizards
mailing list