Hi there
I'm using this script to convert command line history with Epoch time stamp to human readable. While it works fine with users with /bin/csh shell, it fails to convert for users with /bin/bash shell. Why is this happening? I even changed and added * and [0-9] after the # but it still didnt work..any idea what I'm doing wrong?
cat /var/log/user_history/root_history | while read line ; do if [[ $line =~ '^#' ]]; then date -d "@$(echo $line | cut -c2-)"; else echo $line ; fi; done
This is how the original history log look like:
tail /var/log/user_history/root_history
#1348524075
exit
#1348565492
crontab -e
#1348609978
df -kh
#1348610010
exit
#1348644767
df -h
These are my failed attempts
do if [[ $line =~ '^#[0-9]' ]]
do if [[ $line =~ '^#*' ]]
Meanwhile for csh users, I am getting converted logs
# tail /var/log/user_history/Epoch_Convert/upbadm
#+1345026511
exit
#+1345093905
Date is: Thu Aug 16 15:11:45 EST 2012
#+1345097660
Date is: Thu Aug 16 16:13:47 EST 2012
#+1345097660
Date is: Thu Aug 16 16:14:20 EST 2012
#+1345097669
Date is: Thu Aug 16 16:14:29 EST 2012
Could it be because the csh users' history logs have a plus sign "+" but the bash users' dont have the "+" sign?