The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-10-2001
jaxconsultant jaxconsultant is offline
Registered User
  
 

Join Date: Oct 2001
Location: Florida
Posts: 2
Question file date check script

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..
  #2 (permalink)  
Old 10-10-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
Post the relevent sections of the script and I'm sure you'll
get an answer to your question.
  #3 (permalink)  
Old 10-10-2001
JHeliosfear JHeliosfear is offline
Registered User
  
 

Join Date: Jul 2001
Location: Chicago, IL
Posts: 8
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
  #4 (permalink)  
Old 10-10-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
  
 

Join Date: Aug 2001
Location: Virginia, USA
Posts: 438
First let me say... my apologies. My browser went crazy
and only displayed the first 3 lines of the orignial post.
SO.... I did not see the "Example". Since the "relevant"
portion was in fact there...

if ($Filepmtdate = $RUNDATE) ; then

...it was my "visual" error. Again I can only apologize
to jaxconsultant.

No need to get bent out of shape now JH.
  #5 (permalink)  
Old 10-10-2001
jaxconsultant jaxconsultant is offline
Registered User
  
 

Join Date: Oct 2001
Location: Florida
Posts: 2
Smile

Appreciate your quick response on this matter. I'll go ahead and modify it to incorporate your suggestions.
No issue, here, there's enough problems out there...
thanks again both for your assistance.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0