grep "sorted file" inappropriate (was Re: new grep)

Dik T. Winter dik at cwi.nl
Sun Jul 3 03:37:01 AEST 1988


In article <10132 at tekecs.TEK.COM> andrew at frip.gwd.tek.com (Andrew Klossner) writes:
 > []
 > 
 > 	"How about an option (only applicable when patterns start with
 > 	"^") to tell grep that the file is lexically sorted (?what
 > 	order?) so it can terminate if the input line is lexically
 > 	greater than the pattern (s).  This is useful for searching
 > 	through sorted lists (files, dictionaries, etc...)"
 > 
 > If your pattern is a string (no meta-characters), what you really want
 > is a binary search, as implemented by the Berkeley look(1) command.
 > This is a different sort of operation than grep's sequential search,
 > and offering it as a separate command makes sense.
 > 
 > If your pattern contains meta-characters, its position in a sorted list
 > isn't necessarily defined.  For example, when do you stop searching
 > when the pattern is "^.rwx"?  You could define rules that specify when
 > to stop searching for each of several different forms of pattern, based
 > on the existing pattern algebra, but this starts to be more complexity
 > than the problem merits.
 > 
And also, ^ at the start of a pattern has already a meaning.
-- 
dik t. winter, cwi, amsterdam, nederland
INTERNET   : dik at cwi.nl
BITNET/EARN: dik at mcvax



More information about the Comp.unix.wizards mailing list