whegra,
I believe there are versions of "date" out there that provide date subtraction functionality, but here's a thought:
YES_DAY=0
TODAY=$(date +%d)
if [ ${TODAY} = 01 ]
then
[ ${MONTH} = "01" ] && YES_DAY=31
[ ${MONTH} = "02" ] && YES_DAY=31
[ ${MONTH} = "03" ] && YES_DAY=28
[ ${MONTH} = "04" ] && YES_DAY=31
[ ${MONTH} = "05" ] && YES_DAY=30
[ ${MONTH} = "06" ] && YES_DAY=31
[ ${MONTH} = "07" ] && YES_DAY=30
[ ${MONTH} = "08" ] && YES_DAY=31
[ ${MONTH} = "09" ] && YES_DAY=31
[ ${MONTH} = "10" ] && YES_DAY=30
[ ${MONTH} = "11" ] && YES_DAY=31
[ ${MONTH} = "12" ] && YES_DAY=30
fi
There may be an easier way, but I thought I'd toss this out there to get you started. You may also want to modify the above to account for leap years.
You can check out the following page for some more ideas/scripts:
http://unix.about.com/library/weekly/aa070901a.htm
Hope this helps!
Biker
Systems/Network Administrator
LiveFire Labs - Hands-On Technical e-Learning
www.LiveFireLabs.com