[Techtalk] grep question
Mari Wang
mariw at acm.org
Fri Jan 18 15:52:53 EST 2002
[Erin Mulder]
> Does anyone know a way of doing a grep that returns
> extra lines of context around the matching line (much
> like a context diff)? Perhaps an option I'm missing or
> a short shell script?
>From 'man grep':
OPTIONS
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching
lines.
and
-B NUM, --before-context=NUM
Print NUM lines of leading context before matching
lines.
and
-C [NUM], -NUM, --context[=NUM]
Print NUM lines (default 2) of output context.
And for the record: My grep version is grep (GNU grep) 2.4.2
Some combination of those should enable you to get you what you want.
Mari :)
--
Mari Wang - mariw at acm.org
More information about the Techtalk
mailing list