jaywalker wrote: <snip, snip>
it makes me think that I am the only one screaming "No-o-o-o-o! This new way is worse than useless!".
I hear that. I wanted to shout at him, but he is spending his time making large contributions to Mageia.
jaywalker wrote:Thank you for that. I used to learn new programming languages just for fun, back in the day when I could:-) For some reason I have never been able to get comfortable with bash - came to it too late I suppose, but I'll keep trying.
What I need to do is replace the relative timestamps with absolute date/time in the dmesg dump .
Here is a quick untested kludge to play with.
save it as dmesg_dump
chmod +x dmesg_dump
$PWD/dmesg_dump
This should give you something to start hacking around with.
- Code: Select all
#!/bin/bash
_dm_fn=/var/log/dmesg
_dm_birth=$(stat --format=%W $_dm_fn)
while read -r line; do
_char2=${line:1:1}
if [ "$_char2" = " " ] ; then
_shift=2
else
_shift=1
fi
set -- $(IFS='[.] ';echo $line)
_s=$1
_sec=$(echo "$_s + $_dm_birth" | bc)
_date=$(date --date="@$_sec" +'%b %a %H:%M:%S')
set -- $(echo $line)
shift $_shift
line="$@"
echo "$_date $line"
done < $_dm_fn
I can recommend doing a man stat, man date. To understand the set command
man bash followed with
/ set \[
That is slash space space set space backslash left bracket. The / is used by less to search in the man page. q to quit.
To understand IFS, man bash again and do a
/Word Splitting