Sorting output obtain by grep for timestamp -


my file this.

[2013] [ a] info : [handlemessage] handling messages ...  [2013] [ b] info : [handlemessage] message received is: [os     os-evntsvr0-h                 20130404125956465000rfst  m430   f                   ] [2013] [ c] info : [handlemessage] complete handling message.  [2013] [ a] info : [handlemessage] handling messages ...  [2013] [ b] info : [handlemessage] message received is: [os     os-evntsvr0-h                 20130404135956465000rfst  m430   f                   ]  [2013] [ c] info : [handlemessage] complete handling message. 

i want capture message received. (which did) after capturing message have sort time stamp value in third column. contain characters in end. ( eg : above file 20130404125956465000rfst , 20130404135956465000rfst )

i got lot of messages , use command.

gzgrep 'the message received is:' receiver.log.2013-04-04*.gz | cut -d"[" -f5 | sort -t -n -k3 

but sorting numeric won't work due suffix characters. can me on sorting part. need sort in time stamp value.

use sort -nk3.18 exclude last 4 characters in field 3.

from man sort:

-k, --key=keydef sort via key; keydef gives location , type

keydef f[.c][opts][,f[.c][opts]] start , stop position, f field number , c character position in field; both ori‐ gin 1, , stop position defaults line's end. if neither -t nor -b in effect, characters in field counted beginning of preceding whitespace. opts 1 or more single-letter ordering options [bdfgimhnrrv], override global ordering options key. if no key given, use entire line key. e


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -