How long can the line be?
There's no perlrun switch that makes this easy, but regular old IF-ELSIF and a state variable will get the job done.
perl -ne 'if (/PAT/) { print; $aft = 1 } elsif ($aft) { print "$_---\n"; $aft = 0; }' FILENAME
No doubt this could be golf'd into submission, but left reasonably verbose here for clarity.
The bigger question (to me) is, "why?" My system grep implements Perl regular expressions, plus there have been multiple Perl grep implementations such as grepp -- Perl version of grep. There is a point at which the convenience of a one-liner can't make up for the power of a purpose-built utility. Maybe this isn't that point, but it'd be getting awfully close, for me.
use strict; use warnings; omitted for brevity.
|