grep replacement (first match only per file)
John Woods
john at frog.UUCP
Thu Jun 9 14:57:00 AEST 1988
In article <1998 at u1100a.UUCP>, krohn at u1100a.UUCP (Eric Krohn) writes:
> In article <1112 at X.UUCP> john at frog.UUCP (some clown :-) writes:
> ] awk '/^Subject: / { print FILENAME ":" $0; next }' *
>
> This will print Subject: lines more than once per file if a file happens to
> have more than one Subject: line. `Next' goes to the next input line, not
> the next input file, so you are still left with an exhaustive search of all
> the files.
>
Oops. I blew it. Working on GNU awk seems to have permanently damaged my
brain (there are a couple of differences between "real" awk and GNU awk which
I couldn't convince the author were worth changing, specifically in 'exit'
(not next); GNU exit actually does what I thought next would do, instead of
exiting entirely).
--
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