The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comparing 2 strings satish@123 Shell Programming and Scripting 2 05-16-2008 04:59 AM
comparing strings agarwal Shell Programming and Scripting 3 04-16-2008 02:29 AM
Urgent:Comparing two Strings using If Loop Anji Shell Programming and Scripting 2 01-09-2008 05:54 AM
Comparing Two Strings Anji Shell Programming and Scripting 8 01-09-2008 03:32 AM
comparing two strings ragha81 Shell Programming and Scripting 24 09-21-2006 08:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-22-2007
Registered User
 

Join Date: Dec 2006
Posts: 9
Comparing strings

I have two strings
a=Mar22
b=may21

how can I compare them
Is this fine

if[ $a -eq $b ] then;
.
...

else
....
fi

or
if[ $a = $b ] then
Reply With Quote
Forum Sponsor
  #2  
Old 03-22-2007
Registered User
 

Join Date: Feb 2007
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 187
for string comparisions we generally use = operator.
-eq is used for integer comparisons.
if [ "str1" = "str2" ] then

fi

will do your task .
Reply With Quote
  #3  
Old 03-22-2007
Registered User
 

Join Date: Dec 2006
Posts: 9
Many Thanks.It worked now. I tried with out " ".
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 09:57 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