Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!hc!beta!unm-la!unmvax!nmtsun!dieter From: dieter@nmtsun.nmt.edu (Dieter Muller) Newsgroups: comp.unix.wizards Subject: Re: grep replacement Message-ID: <273@nmtsun.nmt.edu> Date: 28 May 88 06:34:08 GMT References: <7882@alice.UUCP> <5630@umn-cs.cs.umn.edu> <6866@elroy.Jpl.Nasa.Gov> <2978@ihlpe.ATT.COM> <1463@laidbak.UUCP> <22969@bu-cs.BU.EDU> Reply-To: dieter@titan.UUCP (Dieter Muller) Organization: New Mexico Tech, Socorro NM Lines: 34 In article <22969@bu-cs.BU.EDU> bzs@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@nmtsun.nmt.edu