linux shell script comparing strings containing spaces
am trying to write a shell script.
I have two strings say str1 and str2
I need to check if str1 and str2 are equal.
I used the following piece of code
if [ $str1 == $str2 ]
echo "strings are equal"
echo "strings are different"
if i run this script and give str1 as hello ,it works fine.but if i give something like hello world it shows an error saying
: too many arguments
I tried giving str 1 as "a b" and got the same error.
So I guess its the space in between characters that gives the error.
Can any1 help me out?