The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: date - 1 day
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-20-2008
sfedak sfedak is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 7
Question 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.