Results 1 to 3 of 3

Thread: comparing dates

  1. #1
    Join Date
    Jan 2005
    Posts
    2

    Unanswered: 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!!

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    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.

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •