Reputation: 35
Please let me know what is error am I doing here. I am getting this output irrespective of the values of a and b variables.
Upvotes: 0
Views: 124
Reputation: 106
Strictly speaking, == is used to compare strings. You'd like to use -eq to compare integer values. In the following example string comparison will fail even if integer value is the same:
a=010
b=10
if [ $a == $b ] ; then
echo "A == B"
else
echo "A <> B"
fi
But if we change test operate to -eq
a=010
b=10
if [ $a -eq $b ] ; then
echo "A == B"
else
echo "A <> B"
fi
Result will be A == B
Upvotes: 0