Hi, $1 is reset on each attempted match, so if a failed match occurs after your last match, $1 will be unset.
perl -ne '$string=$_ if /Successfully sent/; $match = $1 if $string = +~ /^(.*) INFO.*$/; END{print $match}' $logfile
Hope this helps!
In reply to Re: one liner string extraction
by 1nickt
in thread one liner string extraction
by natxo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |