The timestamp in dmesg is in number of seconds.nanoseconds from the system start-up, therefore you should retrieve the start-up time (as returned by the uptime command or from /proc/uptime) and do some calculations. Here is a little awk program to do the trick:
Code:
BEGIN {
"cat /proc/uptime" | getline result
split(result,uptime)
start = systime() - int(uptime[1])
}
$1 ~ /\[[0-9.]+\]/ {
gsub(/\[|\]/,"",$1)
$1 = ("[" strftime("%c",start+int($1)) "]")
}
1
or in a single (long) command line:
Code:
dmesg | awk 'BEGIN {"cat /proc/uptime" | getline result; split(result,uptime); start = systime() - int(uptime[1])} $1 ~ /\[[0-9.]+\]/ {gsub(/\[|\]/,"",$1); $1 = ("[" strftime("%c",start+int($1)) "]")}1'