compare the log and display the time difference..

Hi All,
I've written a script which reads all the systems backup information and saves it in a log file.

#!/bin/ksh
export ORACLE_SID=$1
export primaryhost=$2
export sid=`echo $ORACLE_SID| tr ['A-Z'] ['a-z']`
RESULTFILE=/oracle/PC9/backupstatus_prod.log

LOGP=`ssh -o StrictHostKeyChecking=no -l ora${sid} ${primaryhost} "tail -2 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" |head -1 | awk '{print $3,$4,$5,$6}'` >> ${RESULTFILE}

LOGL=`ssh -o StrictHostKeyChecking=no -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" | awk '{print echo "BEGIN:" $3,$4 echo "END:"$5,$6}'` >> ${RESULTFILE}

The output shows as below:
BEGIN:2009-01-25 02.00.49 END:2009-01-25 08.42.53

Now i need to calculate the current time with the last successfull backup end time and provide the elapsed time (i.e in HOURS).

Example : If the current date and time is 2009-01-28 04.32.57 and in the above output we see the last successful backup has finished at 2009-01-25 08.42.53 so it has to calculate the elapsed hours from then and display the hours...

Any help is highly appreciated...

Thank you ALL..

check the FAQ article:

http://www.unix.com/answers-frequently-asked-questions/13785-yesterdays-date-date-arithmetic.html

HTH