grep replacement

Dieter Muller dieter at nmtsun.nmt.edu
Sat May 28 16:34:08 AEST 1988


In article <22969 at bu-cs.BU.EDU> bzs at bu-cs.BU.EDU (Barry Shein) writes:
>
 [introductory comments deleted]
>Just wondering if a generalization is being missed here somewhere,
>also consider grepping something like a termcap file, maybe what I
>really want is a generalized method to supply pattern matchers for
>what to list on a hit:
>
>	grep -P .+3,.-3 pattern		# print +-3 lines centered on match
>	grep -P ?^[^ \t]?,.+1 pattern	# print from previous line not
>					# beginning with white space to
>					# one past current line
>
 [various drawbacks deleted]
>	-Barry Shein, oston University

Many's the time I would have been willing to make a blood sacrifice for
this kind of capability.  Firing up emacs for /etc/termcap can be a real
pain, when you're A) on a low-speed terminal line (300/1200 baud), B)
looking for something near the end of the file, and C) many things between
the beginning of the file and what you want will match.  Even using
gnumacs in batch mode & writing some lisp to do it strikes me as inelegant.
Starting a 32K search program doesn't hurt nearly as much as starting up
a 1253K search program.

Also, I always use egrep instead of grep, since it is almost always faster.
I don't understand how it is also faster than fgrep, but that's what "time"
says.  Please consider this when picking algorithms.

Dieter (Gnumacs is nice, egrep is better) Muller
-- 
You want coherency, cogency, and literacy all in one posting?  Be real.
...{cmcl2, ihnp4}!lanl!unm-la!unmvax!nmtsun!dieter
dieter at nmtsun.nmt.edu



More information about the Comp.unix.wizards mailing list