Xref: utzoo comp.unix.questions:8203 comp.unix.wizards:9882
Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!emv
From: emv@mailrus.cc.umich.edu (Edward Vielmetti)
Newsgroups: comp.unix.questions,comp.unix.wizards
Subject: Re: cgrep (context-grep)
Keywords: grep
Message-ID: <571@mailrus.cc.umich.edu>
Date: 14 Jul 88 02:58:02 GMT
References: <2985@cvl.umd.edu>
Sender: usenet@mailrus.cc.umich.edu
Reply-To: emv@mailrus.cc.umich.edu (Edward Vielmetti)
Followup-To: comp.unix.questions
Distribution: na
Organization: University of Michigan Computing Center, Ann Arbor
Lines: 24

In article <2985@cvl.umd.edu> arensb@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