Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

Comparing strings

UNIX for Advanced & Expert Users


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-22-2007   -   Original Discussion by yakyaj
yakyaj yakyaj is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 4 June 2007, 1:20 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
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
Sponsored Links
    #2  
Old Unix and Linux 03-22-2007   -   Original Discussion by yakyaj
varungupta varungupta is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 15 July 2010, 5:53 AM EDT
Location: Pune, Dehradun (INDIA), Michigan(US)
Posts: 206
Thanks: 0
Thanked 1 Time in 1 Post
for string comparisions we generally use = operator.
-eq is used for integer comparisons.
if [ "str1" = "str2" ] then

fi

will do your task .
Sponsored Links
    #3  
Old Unix and Linux 03-23-2007   -   Original Discussion by yakyaj
yakyaj yakyaj is offline
Registered User
 
Join Date: Dec 2006
Last Activity: 4 June 2007, 1:20 AM EDT
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Many Thanks.It worked now. I tried with out " ".
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Comparing strings with sed cola Shell Programming and Scripting 7 08-22-2010 12:51 PM
comparing two strings infyanurag Shell Programming and Scripting 1 10-15-2008 03:38 AM
comparing 2 strings satish@123 Shell Programming and Scripting 2 05-16-2008 08:59 AM
comparing strings agarwal Shell Programming and Scripting 3 04-16-2008 06:29 AM
Comparing Two Strings Anji Shell Programming and Scripting 8 01-09-2008 06:32 AM



All times are GMT -4. The time now is 05:16 PM.