[CentOS] grep

Tue Aug 28 14:23:12 UTC 2007
Warren Young <warren at etr-usa.com>

Scott McClanahan wrote:
> grep out the next 5 lines after the first and only instance 

The scope of grep's view of the world is a single line.  At any one 
time, it knows nothing more.

If you need to deal with multiple lines, I suggest perl.  Untested code:

#!/usr/bin/perl
while (<>) {
	if (m/bar/) {
		for ($i = 0; $i < 5 and defined($_); ++$i) {
			print;
			$_ = <>;
		}
		last;
	}
}