in reply to grep -A10 oneliner?

That's grep -A, not grep -b. Grep -b prints byte offsets of the matches.

Update: grep -A10, more precisely.

Replies are listed 'Best First'.
Re^2: grep -A10 oneliner?
by Fletch (Bishop) on Apr 14, 2005 at 20:23 UTC

    Why not both?

    # grep -b -A10 pattern file perl -ne '$c=11if/pattern/;$d=$c<11?"-":":";$t||=0;$c--,print"$t$d$_"i +f$c;$t=tell' file

    Update: This produces the same output as GNU diff which prints --\n between groups farther than the -A amount of lines apart.

    perl -lne 'if(/pattern/){print"--"if!$c&&$t;$c=11};$d=$c<11?"-":":";$t +||=0;$c--,print"$t$d$_"if$c;$t=tell' file