I had a similar problem where I had to get a value based on yesterday. I came up with the following script. I'm sure it could be shortened a bit but it works for me. Here you go...
#!/usr/bin/ksh
#
#
# Use the built-in time command to get the epoch
# time of yesterday. 86400=1 day in seconds.
YESTER_EPOCH=`/usr/bin/perl -e 'printf"%d\n",(time-86400);'`
# Now convert the epoch time into something more usable.
YESTERDAY_TEMP=`perl -e "print scalar(localtime(${YESTER_EPOCH}))"`
# Now parse out the month, day, and year.
MONTH_TEMP=`print ${YESTERDAY_TEMP} | cut -d" " -f2`
DAY_TEMP=`print ${YESTERDAY_TEMP} | cut -d" " -f3`
YEAR=`print ${YESTERDAY_TEMP} | cut -d" " -f5 | cut -c3-4`
# Convert the month text into a number format
case "${MONTH_TEMP}" in
Jan)
MONTH=01
;;
Feb)
MONTH=02
;;
Mar)
MONTH=03
;;
Apr)
MONTH=04
;;
May)
MONTH=05
;;
Jun)
MONTH=06
;;
Jul)
MONTH=07
;;
Aug)
MONTH=08
;;
Sep)
MONTH=09
;;
Oct)
MONTH=10
;;
Nov)
MONTH=11
;;
Dec)
MONTH=12
;;
esac
# Convert the day to 2 digits if not already
case "${DAY_TEMP}" in
1)
DAY=01
;;
2)
DAY=02
;;
3)
DAY=03
;;
4)
DAY=04
;;
5)
DAY=05
;;
6)
DAY=06
;;
7)
DAY=07
;;
8)
DAY=08
;;
9)
DAY=09
;;
*)
DAY=${DAY1_TEMP}
esac
# From here you can continue with the code that INCREDIBLE posted above.
MYDATE=`ls -l *_${YEAR}${MONTH}${DAY}*_${YEAR}${MONTH}${DAY}* | wc -l`
if [ ${MYDATE} -eq 2714 ]
then
echo "Good"
exit 1
else
echo "Bad"
fi
Hope this is what you're trying to do.
Bruhn