Skip to content

Instantly share code, notes, and snippets.

@fcolista
Created February 7, 2017 07:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fcolista/3b62c1a67f8c6d22ad9943dde89941fb to your computer and use it in GitHub Desktop.
Save fcolista/3b62c1a67f8c6d22ad9943dde89941fb to your computer and use it in GitHub Desktop.
dmesg output date in a human readable way
#!/bin/sh
# It's better to have dmesg logging in a human readable way
base=$(cut -d '.' -f1 /proc/uptime);
seconds=$(date +%s);
dmesg | sed 's/\]//;s/\[//;s/\([^.]\)\.\([^ ]*\)\(.*\)/\1\n\3/' |
while read first; do
read second;
first=`date +"%d/%m/%Y %H:%M:%S" --date="@$(($seconds - $base + $first))"`;
printf "[%s] %s\n" "$first" "$second";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment