in reply to Grep - print matched line and next N lines
Plus or minus a few parameters, of course.$n = 0; while (<>) { $n = 7 if /$pattern/; # start printing if ($n) { print; $n-- } # print if within $n = 0 if eof; # don't leak across file boundaries }
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: Grep - print matched line and next N lines
by runrig (Abbot) on Aug 13, 2002 at 17:23 UTC |