in reply to one liner string extraction
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!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: one liner string extraction
by vr (Curate) on Nov 02, 2017 at 15:33 UTC | |
|
Re^2: one liner string extraction
by natxo (Scribe) on Nov 02, 2017 at 12:00 UTC |