natxo has asked for the wisdom of the Perl Monks concerning the following question:
The line something like this:perl -ne '$string=$_ if /Successfully sent/; END{print $string}' $log +file
Now I need to get just the timestamp at the beginning of this line. This is how I thought it should work:2017-11-02 12:08:11,120 INFO [Timer-Driven Process Thread-8] o.a.nifi. +remote.StandardRemoteGroupPort RemoteGroupPort[name=Receiver,targets= +https://host.sub.domain.tld:9443/nifi] Successfully sent [StandardFlo +wFileRecord[uuid=xxxxxxxxxxxx,claim=StandardContentClaim [resourceCla +im=StandardResourceClaim[id=xxx, container=default, section=xxx], off +set=384244, length=163820],offset=0,name=xxxxx.json,size=163820]] (15 +9.98 KB) to https://host.sub.domain.tld:9443/nifi-api in 242 millisec +onds at a rate of 660.28 KB/sec
But no success until now. Any tips greatly appreciated. Thanks in advance!perl -ne '$string=$_ if /Successfully sent/; $string =~ /^(.*) INFO.* +$/; END{print $1}' $logfile
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: one liner string extraction
by 1nickt (Canon) on Nov 02, 2017 at 11:37 UTC | |
by vr (Curate) on Nov 02, 2017 at 15:33 UTC | |
by natxo (Scribe) on Nov 02, 2017 at 12:00 UTC | |
|
Re: one liner string extraction
by kcott (Archbishop) on Nov 03, 2017 at 13:30 UTC |