cgrep (context-grep)

Edward Vielmetti emv at mailrus.cc.umich.edu
Thu Jul 14 12:58:02 AEST 1988


In article <2985 at cvl.umd.edu> arensb at lemuria.UUCP (Andrew Arensburger) writes:
>
>	I'm thinking of writing a utility called cgrep, which works just
>like grep, but instead of writing out just the line on which the pattern
>was found, would write out a couple of lines surrounding the line in
>question.

when I needed to do this recently, this is what I cooked up on the
spur of the moment.  It works, though it's by no means optimal.

cgrep:
#!/bin/sh
grep -v $1 $2 | diff -c - $2

all depends on whether your diff can handle standard input or now.
mine can (Apollo SR 10 beta).

You might note that there was a long discussion of 'gre', a new
project from at&t research to do grep right, and as I recall the
prevailing view from the "tools, pipes, filters" crowd was
that context doesn't belong in grep.  The "features, features,
features" crowd thought otherwise.
I'd be interested in a cgrep if you wrote one.

--Ed



More information about the Comp.unix.questions mailing list