[Techtalk] grep question
Telsa Gwynne
hobbit at aloss.ukuu.org.uk
Fri Jan 18 15:13:45 EST 2002
On Fri, Jan 18, 2002 at 08:35:51AM -0500 or thereabouts, Erin Mulder wrote:
> 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?
I use -B n and -A n. Looking at grep --help, I realise I could
have saved myself another character or two:
Context control:
-B, --before-context=NUM print NUM lines of leading context
-A, --after-context=NUM print NUM lines of trailing context
-C, --context[=NUM] print NUM (default 2) lines of output context
unless overridden by -A or -B
-NUM same as --context=NUM
Telsa
More information about the Techtalk
mailing list