Tuesday, March 11, 2008

A Perl one-liner to convert the ITM61 timestamps into readable format

There are so many different timestamps in ITM6.1 and I give below a Perl one liner to convert the timestamps in ITM6 logs into "human readable" format.

The timestamp used in the logs is the epoch time in seconds, i.e. number of seconds since 1970, converted into hexadecimal format! The following Perl one liner converts the timestamp into human readable format.

perl -lane 'if ($_ =\ /^(.)([\dA-F]+)(\..*)/) { printf "%s%s%s", $1, scalar(localtime(oct("0x$2"))),$3

No comments: