wgrep.pl as listed at this link will do it.
http://www.unix.com/solaris/33533-grep-display-few-lines-before-after.html
Or just use grep at the command line or qx() with the -B and -A options to specify the number of lines before and after.
In reply to Re: Print Lines above and below string
by Gulliver
in thread Print Lines above and below string
by coding_new
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |