The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

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
Comparing Two Strings Anji Shell Programming and Scripting 8 01-09-2008 02:32 AM
Comparing strings yakyaj UNIX for Advanced & Expert Users 2 03-22-2007 09:22 PM
comparing two strings ragha81 Shell Programming and Scripting 24 09-21-2006 08:52 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-08-2008
Registered User
 

Join Date: Jan 2008
Posts: 21
Stumble this Post!
Urgent:Comparing two Strings using If Loop

Hi All,

Please help me out in this... I am new to scripting

How to compare two strings by using the same string in single loop,
I am using ksh

for ex:see the code snippet below
I am writing in java,
Can u guys tell me that in scripting

if ("string1"=="string2" || "string1"=="string3")
{
//statements----
}
else
if("string2"="string3")
{
//statements
}

Thanks in advance.
Anji
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-09-2008
sysgate's Avatar
Unix based
 

Join Date: Nov 2006
Location: /root
Posts: 1,160
Stumble this Post!
in java (copied from the net, handy ):
Quote:
String s = "something", t = "maybe something else";
if (s == t) // Legal, but usually WRONG.
if (s.equals(t)) // RIGHT
if (s > t) // ILLEGAL
if (s.compareTo(t) > 0) // CORRECT>
in ksh :
Quote:
if [[ $foo = "bar" ]];then
# commands....
fi
Reply With Quote
  #3 (permalink)  
Old 01-09-2008
Registered User
 

Join Date: Jan 2008
Posts: 21
Stumble this Post!
Thanks buddy

I already solved that problem by own

Anyway Thanks alot for ur reply
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 05:27 PM.


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

Content Relevant URLs by vBSEO 3.2.0