Home Man
Search
Today's Posts
Register

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

Tags
advanced

Login to Reply

 
Thread Tools Search this Thread
# 1  
Old 03-22-2007
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
# 2  
Old 03-22-2007
for string comparisions we generally use = operator.
-eq is used for integer comparisons.
if [ "str1" = "str2" ] then

fi

will do your task .
# 3  
Old 03-23-2007
Many Thanks.It worked now. I tried with out " ".
Login to Reply

« Previous Thread | Next 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
Comparing Strings in ksh88 smile689 Shell Programming and Scripting 2 07-01-2013 03:29 AM
comparing strings as ints vsekvsek Shell Programming and Scripting 2 08-27-2012 01:58 PM
Help with Comparing 2 strings from text aLHaNz Shell Programming and Scripting 4 07-23-2011 01:53 PM
Comparing strings with sed cola Shell Programming and Scripting 7 08-22-2010 11:51 AM
Comparing strings using nawk ganiel24 Shell Programming and Scripting 6 06-25-2009 09:59 AM
comparing two strings infyanurag Shell Programming and Scripting 1 10-15-2008 02:38 AM
comparing 2 strings satish@123 Shell Programming and Scripting 2 05-16-2008 07:59 AM
comparing strings agarwal Shell Programming and Scripting 3 04-16-2008 05:29 AM
Comparing Two Strings Anji Shell Programming and Scripting 8 01-09-2008 05:32 AM
comparing two strings ragha81 Shell Programming and Scripting 24 09-21-2006 11:52 AM


All times are GMT -4. The time now is 04:01 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
UNIX.COM Login
Username:
Password:  
Show Password