in reply to upto match please, my one-lina!!
Howzabout this?
You can even slice @t in the print if you want to have a larger gap between the last printed item and the regular expression...perl -ne 'print @t if /foo/; push @t,$_; shift @t if $#t>5' file
UPDATE: I golfed it down a little:
--roboticusperl -ne 'print @t if /foo/; @t=(@t[1..4],$_)' file
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: upto match please, my one-lina!!
by jwkrahn (Abbot) on Jun 09, 2006 at 03:56 UTC | |
by roboticus (Chancellor) on Jun 09, 2006 at 04:05 UTC | |
by jwkrahn (Abbot) on Jun 09, 2006 at 09:15 UTC |