simbabarry simbabarry - 1 year ago 85
Linux Question

extract log time from log file

How do I extract the time part only from a string like this.

[20/06/2016 15:55:42.079] <Messenger> Echo test request

I just want to get this part 15:55:42.079 from the log.

sat sat
Answer Source

You can try this:

awk -F']| ' '{print $2}' <<< "STRING"


$ awk -F']| ' '{print $2}' <<< "[20/06/2016 15:55:42.079] Echo test request"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download