grep replacement

Root Boy Jim rbj at cmr.icst.nbs.gov
Thu Jun 16 02:09:19 AEST 1988


? From: andrew at alice.uucp
? 
? 4) print one(first matching) line and go onto the next file.
? 	most of the justification for this seemed to be scanning
? 	mail and/or netnews articles for the subject line; neither
? 	of which gets any sympathy from me. but it is easy to do
? 	and doesn't add an option; we add a new option (say -1)
? 	and remove -s. -1 is just like -s except it prints the matching line.
? 	then the old grep -s pattern is now grep -1 pattern > /dev/null
? 	and within epsilon of being as efficent.

I often grep for a host name in /etc/hosts. This is a big file and
would benefit from the execution time saved. Yeah, I know, use sed,
it's only one file. OK, how about this: grep -1 '#include .thing.' *.c?
 
? 5) divert matching lines onto one fd, nonmatching onto another.
? 	sorry, run grep twice.

While I rarely want to do this, the times I have, I have been extremely
annoyed. Why should I have to suffer twice the execution time when it
is trivial to put this in?
 
? Thus, the current proposal is the following flags. it would take a GOOD
? argument to change my mind on this list (unless it is to get rid of a flag).

? -h	do not print filenames in front of matching lines
? -H	always print filenames in front of matching lines

It has already been shown how to do these: for the former, use
cat files | grep, for the latter, grep files /dev/null. Perhaps
you are being a tad inconsistant with the tools philosophy?

? -e expr	use expr as the pattern

What about the magic `--' getopt token? Do we need `-e'?

? Andrew Hume
? research!andrew
 
	(Root Boy) Jim Cottrell	<rbj at icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
	My name is in /usr/dict/words. Is yours?



More information about the Comp.unix.wizards mailing list