Hi, no sed, use Perl natively for this! It's what Perl is made for. Open the file, loop through the lines, save the last instance of YYY, print it when you find ABC.
Output:use strict; use warnings; my $last_seen; for my $line ( <DATA> ) { $last_seen = $line if $line =~ /YYY/; print $last_seen if $line =~ /ABC/; } __DATA__ something something YYY first something something YYY second something ABC something
$ perl ~/monks/1223838.pl YYY second
Hope this helps!
In reply to Re: Sed in perl
by 1nickt
in thread Sed in perl
by abhay180
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |