I have written below script:
#!/usr/bin/bash
STR_1="nfosys"
STR_2="Infosys"
if (( $STR_1 == $STR_2 ))
then
echo "Strings are equal"
else
echo "Strings are not equal"
fi
Getting Output:
root:~/Desktop/user_repo/Demo# bash -x test.sh
+ STR_1=nfosys
+ STR_2=Infosys
+ (( nfosys == Infosys ))
+ echo 'Strings are equal'
Strings are equal
root:~/Desktop/user_repo/Demo#
Ideally it should print "Strings are not equal" statment but i am unable to understand why it is printing "Strings are equal"
nfosysandInfosysare being obtained and what they actually are while the script is being run.==inside of(())is used for comparing numbers, use[[instead for strings.