Xref: utzoo comp.unix.wizards:9057 comp.unix.questions:7365 Path: utzoo!utgpu!water!watmath!clyde!bellcore!rutgers!ucsd!ames!necntc!frog!john From: john@frog.UUCP (John Woods) Newsgroups: comp.unix.wizards,comp.unix.questions Subject: Re: grep replacement Message-ID: <1112@X.UUCP> Date: 2 Jun 88 04:39:00 GMT References: <7882@alice.UUCP> <590@root44.co.uk> Organization: Servants of the Great White Frog Lines: 23 In article <590@root44.co.uk>, gwc@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@frog.UUCP, ...!mit-eddie!jfw, jfw@eddie.mit.edu No amount of "Scotch-Guard" can repel the ugly stains left by REALITY... - Griffy