in reply to Getting next line after matched one

perl -ne 'print if $,;$, = /PATTERN/' input
Note that this also works if you have two (or more) consecutive lines matching PATTERN - it prints all of them except the first, and the line following it. It won't try to read past eof either.

Replies are listed 'Best First'.
Re^2: Getting next line after matched one
by sgifford (Prior) on Dec 31, 2004 at 17:50 UTC
    Is there any advantage to using $, here besides an obscurity bonus? :)