Date comparison using ksh

Hi All,

i have a text sample below.

rootdbs 1 0 01/03/2010.03:11
physdbs 2 0 01/03/2010.03:17
logdbs01 3 0 01/03/2010.03:17
logdbs02 4 0 01/03/2010.03:17
dbs01 5 0 01/03/2010.03:17
dbs02 6 0 01/03/2010.03:17
dbs03 7 0 01/03/2010.03:17
dbs04 8 0 01/03/2010.03:17

What i want to achieve is:

  1. create a variable that will display
    YYYY=today's year
    DD=today's day
    MM=today's month

  2. compare the $4 on the text above to the date in number 1.

  3. if the date does not match for x days (where x is the number of days), it will send an email to me.

What have you tried?

If you have gnu date, you can use

date -d "01/03/2010 03:11" +%s 

to get the seconds since 1970-01-01 00:00:00 UTC, which compare the today's seconds with X days.

We'll, The main objective actually is to loop from the dates on a per row basis and compare it with the current date. I don't want to get up to the seconds. If the dates are not equal and more than 3 days, it will send alert to me.

e.g.
DATETODAY=`date +D`
DATEBK=backup date

loop on a per row basis, then compare on a per row basis vs. DATETODAY.

All date comparison should be performed with epoch ( number of seconds since 1970 ) .
Otherwise you need to write very complex code .
So , convert both dates to epoch , subtract from the first number 3*24*3600 and compare them as 2 numbers .

Thank you for your reply. can you provide me some examples of the loop? I try to do it but it displays all the dates.

for i in 1.....10
do
datebk=onstat -g arc|awk '{print $4}'
echo $datebk
echo
done

the output of onstat -g arc|awk '{print $4}' is the whole output, i want to manipulate the output on a per row basis.