Xref: utzoo comp.unix.wizards:9306 comp.unix.questions:7557 Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!necntc!frog!john From: john@frog.UUCP (John Woods) Newsgroups: comp.unix.wizards,comp.unix.questions Subject: Re: grep replacement (first match only per file) Summary: Oops. Message-ID: <1123@X.UUCP> Date: 9 Jun 88 04:57:00 GMT References: <7882@alice.UUCP> <590@root44.co.uk> <1112@X.UUCP> <1998@u1100a.UUCP> Organization: Servants of the Great White Frog Lines: 21 In article <1998@u1100a.UUCP>, krohn@u1100a.UUCP (Eric Krohn) writes: > In article <1112@X.UUCP> john@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@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu No amount of "Scotch-Guard" can repel the ugly stains left by REALITY... - Griffy