Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Function in UNIX

Status
Not open for further replies.

davidku

Programmer
Aug 6, 2002
24
MY
Hi Gurus,

I am writing a script to automatically mget ( ftp ) files from a remote server to my local machine.

xfile="datafile_`date +%y%m`*"

in my FTP script, I'll just mget $xfile

The problem I am facing is ... I need to retrieve data files for DAY - 1.

I can get the DAY variable and then -1 from it but it requires a lot of logic when comes to month end.

Example :

mget datafile_030604*

Let's say, today is MARCH 1st. 01 is my day and I cannot be the day set to 0.

Just want to check with you guys any idea how I can simplify this task ?

Thanks a lot ...

 
Here's a useful bit of code (and construct) for Korn Shell that I use here in the UK, to get date (and time) information 'in the past':

Code:
saved_TZ="${TZ}"
export TZ="GB+24:00"   # this is for 24 hours ago in GB Timezone
date_code=`date`
export TZ="${saved_TZ}"


I hope that helps.

Mike
 
faq822-4802

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top