date - 1 day
Hi, I have been trying just about every unix command to come up with yesterday's date (today's date - 1). I have seen all of the help on this forum, and none of it seems to work for me here. We are using Sun Solaris 9 Unix. I am using this script to create a .txt file with ftp commands that I will run from another script. All I want to do, is retrieve whatever files are at the ftp site with a date of yesterday in the filename. I have been trying to get the date right with Unix but obviously I am not having much luck.
I have tried a number of ways to get yesterday's date and none work for me.
#CalcDate=`date +%Y%m%d`
#CalcDate=`date -d yesterday +%Y%m%d`
#date="1 day ago" +"%Y%d%m"
I am able to output today's date to the .txt file using the following (see below).
CalcDate=`date +%Y%m%d`
cd /apps/PT8.44/outputs/backflow
echo 'lcd /apps/PT8.44/outputs/backflow/test' > bflowin.txt
echo 'mget *'$CalcDate* >> bflowin.txt
echo 'quit' >> bflowin.txt
Contents of bflowin.txt after script runs: I need it to be 20081119 (yesterday's date).
lcd /apps/PT8.44/outputs/backflow/test
mget *20081120*
quit
Any help you guys can give would be appreciated.
|