in reply to Epoch time conversion script

What an abomination ! . Replace the program with:
perl -e 'print ( (stat(shift))[8] . "\n") ' s32adm_bash_history
If you really want to diagnose it, you will need to find out what you are passing into the function.
In particular, what is the value of $fday ?

Also - your program does NOT make it's output human-readable - indeed , quite the reverse - it converts human time into Unix Epoch.

             All great truths begin as blasphemies.
                   ― George Bernard Shaw, writer, Nobel laureate (1856-1950)

Replies are listed 'Best First'.
Re^2: Epoch time conversion script
by hedkandi (Initiate) on Mar 28, 2012 at 04:48 UTC
    Hi netwallah

    I am trying to convert the epoch time to local time. I can use a one-liner that does the job but it's tedious to do it manually with many users on the system

    cat /var/log/user_history/32adm_bash_history | while read line ; do i +f [[ $line =~ '^#' ]]; then date -d "@$(echo $line | cut -c2-)"; els +e echo $line ; fi; done

      Could you please post some sample lines from 32adm_bash_history so we can see the format of your file? And what your expected output would look like?

        Hi anonymous This is the sample history file with hashed Epoch time in seconds taken from a different user:

        [root@H99A105 user_history]# tail -f sapr3_history #+1331257705 Date is: Fri Mar 9 10:48:25 JST 2012 #+1331257706 history

        After the conversion it should look like this:

        [root@H99A105 user_history]# tail -f /var/log/user_history/Epoch_Conve +rt/sapr3 Fri Mar 9 10:48:25 JST 2012 Date is: Fri Mar 9 10:48:25 JST 2012 Fri Mar 9 10:48:26 JST 2012 history