[Techtalk] grep question
mariw at acm.org
Fri Jan 18 15:52:53 EST 2002
> 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':
-A NUM, --after-context=NUM
Print NUM lines of trailing context after matching
-B NUM, --before-context=NUM
Print NUM lines of leading context before matching
-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 Wang - mariw at acm.org
More information about the Techtalk