There is one function to calculate previous day value and then touch one file with that date.The problem is i am getting the previous day value but not able to store it in other variable and use it.
PREVIOUS_DATE_FUNCTION()
{
date '+%m %d %Y' |
{
read MONTH DAY YEAR
DAY=`expr "$DAY" - 1`
case "$DAY" in
0)
MONTH=`expr "$MONTH" - 1`
case "$MONTH" in
0)
MONTH=12
YEAR=`expr "$YEAR" - 1`
;;
esac
DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
esac
PREVIOUS_TEMP_DATE=$YEAR-$MONTH-$DAY
echo "$PREVIOUS_TEMP_DATE"
}
}
PREVIOUSDATE="`(PREVIOUS_DATE_FUNCTION)`"
tempfile=CANCEL_FILE_$PREVIOUSDATE
It would seem that PREVIOUSDATE is ending up null, which means the function must be failing. I showed an alternate way to get yesterday's date without having to call a function.