You are heregrep include lines above and below with awk

grep include lines above and below with awk


awk include lines before

awk 'BEGIN {W=4} {line[i++%W]=$0} /targetstring/{for (j=i-W;j<i;j++) { print line[j%W] }}' file-to-search

awk include lines before and after
awk 'BEGIN {W=5} {line[i++%W]=$0; if (1==x--){for (j=i-W;j
via http://forums13.itrc.hp.com/service/forums/questionanswer.do...

Tags