Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Comparison 1

Status
Not open for further replies.

igg

Programmer
Feb 20, 2002
9
IE
I am getting the following output when comparing 2 strings...
String 1 is : 1702
String 2 is : 1702
./test2.sh[9]: [1702: not found

Strings NOT equal


my code is as follows....
Code:
#! /bin/ksh

STRING1="1702"
STRING2="1702"

echo "String 1 is : $STRING1"
echo "String 2 is : $STRING2"

if ["$STRING1" = "$STRING2"]
then
        echo "\nStrings equal"
else
        echo "\nStrings NOT equal"
fi

Can someone please tell me what I'm doing wrong
 
Replace this:
if ["$STRING1" = "$STRING2"]
By this:
if [ "$STRING1" = "$STRING2" ]

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top