grep replacement

John Woods john at frog.UUCP
Thu Jun 2 14:39:00 AEST 1988


In article <590 at root44.co.uk>, gwc at root.co.uk (Geoff Clare) writes:
> Most of the useful things people have been saying they would like to be
> able to do with 'grep' can already be done very simply with 'sed'.
> For example:
>     Stop after first match:   sed -n '/pattern/{p;q;}'

Close, but no cigar.  It does not work for multiple input files.
(And, of course, spawning off a new sed for each file defeats the basic desire
of most of the people who've asked for it:  speed)

However,

	awk '/^Subject: /	{ print FILENAME ":" $0; next }' *

does (just about) work.  And it's probably not _obscenely_ slow.
(it doesn't behave for no input files, and you might prefer no FILENAME: for
just a single input file)
-- 
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu

No amount of "Scotch-Guard" can repel the ugly stains left by REALITY...
		- Griffy



More information about the Comp.unix.questions mailing list