![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| check the current date file in directory | pallvi | SUN Solaris | 2 | 01-04-2008 05:57 PM |
| how to check whether the given file is 5 weeks older than current date | risshanth | Shell Programming and Scripting | 1 | 10-29-2007 04:53 AM |
| Have a shell script check for a file to exist before processing another file | heprox | Shell Programming and Scripting | 3 | 11-14-2006 03:26 AM |
| check file date in one week ??? | sabercats | Shell Programming and Scripting | 1 | 03-16-2006 08:43 AM |
| Script to check for a file, check for 2hrs. then quit | mmarsh | UNIX for Dummies Questions & Answers | 2 | 09-16-2005 02:46 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I am creating a KSH script and need to check the filedate against the system date. I can get the sys date w. date command, and I was able to get the filedate w. the awk command but when I compare them w. an if condition statement I get syntax error.
Not sure what's wrong, and other suggestions on best approach is welcome. ![]() Here is an example: RUNDATE=$(date + %b%e) Filepmtdate=$(ls -l filename | awk '{print $6,$7}') if ($Filepmtdate = $RUNDATE) ; then do this, so that, fi this will produce the date results but it gives me syntax error and aborts. Last edited by jaxconsultant; 10-10-2001 at 01:43 PM.. |
|
||||
|
Corrected Syntax Errors
Unlike the other person who posted a reply to you, there is NO need to post the "relevant" portion of your script. Nevertheless, using the script structure that you have created, I think that you will find the following commands to work:
RUNDATE=`date '+%b %e'` Filepmtdate=`ls -l filename | awk '{print $6,$7}'` if [ "$Filepmtdate" = "$RUNDATE" ] then ENTER COMMANDS WITHOUT THE "do" command. fi The main changes that I have made, in case you did not catch them, was 1. Replace the parentheses with single, right-directed quotes. 2. Add a space between the %b and %e 3. Change the "if" statement line to the appropriate format as I have shown. 4. Remove the "do" statement after the if statement. "do" statements typically follow "for" commands. I ran a sample script with the above format to output the line "Test completed successfully. The dates are the same" and it worked just fine. Take care. JHeliosfear |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|