If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > comparing dates

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-04-05, 17:07
ask ask is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
comparing dates

Hi!

I'm totally new to shell programming and am trying to write a script for the following task: when the files come from another system, I need to make sure that the datetime on certain file (say, date_cntrl.txt) matches today's date and if it does, execute another script. We are running Solaris here.

I would appreciate any help!

P.S. I am also looking for a web-site that could be of help in figuring out syntax information and general info on UNIX commands. Listing options and switches for all commands etc.

Thanks!!
Reply With Quote
  #2 (permalink)  
Old 01-05-05, 10:12
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,454
This I think should do the trick:

find /directory_where_the_files_are -name "date_cntrl.txt" -mtime 0 -exec ./your_another_script.sh \;

The above will attempt to find the file with the specified name that is modified today and if found, execute whatever is between "-exec" and "\;"

Note that when you ftp files from another system they'll always have the current date on your local machine regardless of when they actually were created on the remote machine.

As for the unix command help, "man <command>" will give you the description of options and behaviour of the specified command. Try "man find", for example.
Reply With Quote
  #3 (permalink)  
Old 01-05-05, 10:25
ask ask is offline
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks, n_i!

I hope that'll work for me. It does sound ike an elegant solution and thanks a lot for the tip regarding the files getting current datetime stamp after FTP.

I knew about man but I guess it takes some time to get used to it Just like anything else, anyway. I was able to find this page, though, that looks like a pretty good reference: http://cdfinfo.in2p3.fr/Services/Inf...OCU/munix.html
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On