file date check script | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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

file date check script

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-10-2001
jaxconsultant jaxconsultant is offline
Registered User
 
Join Date: Oct 2001
Last Activity: 12 October 2001, 9:15 AM EDT
Location: Florida
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
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..
Sponsored Links
    #2  
Old 10-10-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
 
Join Date: Aug 2001
Last Activity: 16 October 2009, 2:04 PM EDT
Location: Virginia, USA
Posts: 438
Thanks: 0
Thanked 1 Time in 1 Post
Post the relevent sections of the script and I'm sure you'll
get an answer to your question.
Sponsored Links
    #3  
Old 10-10-2001
JHeliosfear JHeliosfear is offline
Registered User
 
Join Date: Jul 2001
Last Activity: 10 October 2001, 2:48 PM EDT
Location: Chicago, IL
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
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  
Old 10-10-2001
rwb1959's Avatar
rwb1959 rwb1959 is offline
Registered User
 
Join Date: Aug 2001
Last Activity: 16 October 2009, 2:04 PM EDT
Location: Virginia, USA
Posts: 438
Thanks: 0
Thanked 1 Time in 1 Post
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.
Sponsored Links
    #5  
Old 10-10-2001
jaxconsultant jaxconsultant is offline
Registered User
 
Join Date: Oct 2001
Last Activity: 12 October 2001, 9:15 AM EDT
Location: Florida
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Bug

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.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Date check script (noob) drey4184 UNIX for Dummies Questions & Answers 3 12-21-2011 02:24 PM
finding date numeral from file and check the validity of date format manas_ranjan Shell Programming and Scripting 10 11-18-2011 02:58 PM
Please help I want script to check filename, size and date in specify path. akeji Shell Programming and Scripting 1 06-24-2011 01:37 PM
Script to check file with previous date deepaksingla Shell Programming and Scripting 1 02-17-2011 11:48 AM
Perl Script to check file date and size DallasT Shell Programming and Scripting 26 04-20-2010 06:22 PM



All times are GMT -4. The time now is 08:55 PM.