The UNIX and Linux Forums  

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
bash date format vadharah UNIX for Dummies Questions & Answers 1 04-01-2008 10:37 AM
Perl: Extracting date from file name and comparing with current date MKNENI Shell Programming and Scripting 4 03-26-2008 01:01 PM
Simple date and time calulation in BASH ripat Tips and Tutorials 0 10-08-2006 03:15 AM
BASH : Find files by date and shred them cbismuth Shell Programming and Scripting 2 06-13-2005 08:20 AM
Comparing files named by date/time gillr UNIX for Dummies Questions & Answers 2 05-30-2005 04:37 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-11-2006
Registered User
 

Join Date: Jul 2006
Posts: 9
Bash comparing date

Cound anyone help me on how to compare date in Unix using if function on bash file?

current=date

if ["$current" = 7/12/06] ###syntax is wrong, could anyone correct it for me
then
rm -rf /usr/local/src
fi

Thank You...
Reply With Quote
Forum Sponsor
  #2  
Old 07-11-2006
Registered User
 

Join Date: Jul 2006
Posts: 9
Can anyone give me the syntax for the date to be recognize as date:[yyyy-mm-d]?
Reply With Quote
  #3  
Old 07-11-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Quote:
Originally Posted by Stanford Co
Cound anyone help me on how to compare date in Unix using if function on bash file?

current=date

if ["$current" = 7/12/06] ###syntax is wrong, could anyone correct it for me
then
rm -rf /usr/local/src
fi

Thank You...
Notice the whitespace.

Code:
if [ "$current" = "7/12/06" ] ; then
rm -rf /usr/local/src
fi
Reply With Quote
  #4  
Old 07-11-2006
Registered User
 

Join Date: Jul 2006
Posts: 9
it still doesn't work. date:command not found.

#!/bin/sh

current=date
if ["$current" = "7/12/06"]
then
echo "test"
fi
Reply With Quote
  #5  
Old 07-11-2006
Registered User
 

Join Date: Jul 2006
Posts: 9
it worked!!! I just need to put the white spacing.. Thank You
Reply With Quote
  #6  
Old 07-11-2006
Registered User
 

Join Date: Jul 2006
Posts: 9
the bash file worked with no error. But its not comparing the date i wanted it to be executed. Please help. Thank You.
Reply With Quote
  #7  
Old 07-11-2006
Hitori's Avatar
Registered User
 

Join Date: Jun 2006
Posts: 360
There are plenty posts about date comparison on this forum, try to search first
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:39 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0