Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ingmarioalberto/9862dffd111cd32e1a354df42e6804c1 to your computer and use it in GitHub Desktop.
Save ingmarioalberto/9862dffd111cd32e1a354df42e6804c1 to your computer and use it in GitHub Desktop.
Date & Time in dmesg (human)
dmesg_human () { $(type -P dmesg) "$@" | perl -w -e 'use strict;
my ($uptime) = do { local @ARGV="/proc/uptime";<>}; ($uptime) = ($uptime =~ /^(\d+)\./);
foreach my $line (<>) {
printf( ($line=~/^\[\s*(\d+)\.\d+\](.+)/) ? ( "[%s]%s\n", scalar localtime(time - $uptime + $1), $2 ) : $line )
}'; }
// https://stackoverflow.com/questions/13890789/convert-dmesg-timestamp-to-custom-date-format
// cred: https://stackoverflow.com/users/636849/lucas-cimon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment