Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

From : http://stackoverflow.com/questions/14036116/convert-timestamp-to-datetime-with-sedhttps://stackoverflow.com/questions/14036116/convert-timestamp-to-datetime-with-sed

with bit of scripting...

ping -D localhost | while read row do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" done 

Runs as

$ ping -D localhost | while read row; do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" ; done PING localhost (127.0.0.1) 56(84) bytes of data. [2014-11-10 16:06:40.145811] 64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.045 ms [2014-11-10 16:06:41.144926] 64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.040 ms 

From : http://stackoverflow.com/questions/14036116/convert-timestamp-to-datetime-with-sed

with bit of scripting...

ping -D localhost | while read row do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" done 

Runs as

$ ping -D localhost | while read row; do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" ; done PING localhost (127.0.0.1) 56(84) bytes of data. [2014-11-10 16:06:40.145811] 64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.045 ms [2014-11-10 16:06:41.144926] 64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.040 ms 

From : https://stackoverflow.com/questions/14036116/convert-timestamp-to-datetime-with-sed

with bit of scripting...

ping -D localhost | while read row do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" done 

Runs as

$ ping -D localhost | while read row; do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" ; done PING localhost (127.0.0.1) 56(84) bytes of data. [2014-11-10 16:06:40.145811] 64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.045 ms [2014-11-10 16:06:41.144926] 64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.040 ms 
Post Migrated Here from serverfault.com (revisions)
Source Link

From : http://stackoverflow.com/questions/14036116/convert-timestamp-to-datetime-with-sed

with bit of scripting...

ping -D localhost | while read row do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" done 

Runs as

$ ping -D localhost | while read row; do awk '{ sub(/[0-9]{10}/, strftime("%Y-%m-%d %H:%M:%S", substr($0,2,10))) }1' <<< "$row" ; done PING localhost (127.0.0.1) 56(84) bytes of data. [2014-11-10 16:06:40.145811] 64 bytes from localhost (127.0.0.1): icmp_req=1 ttl=64 time=0.045 ms [2014-11-10 16:06:41.144926] 64 bytes from localhost (127.0.0.1): icmp_req=2 ttl=64 time=0.040 ms