echo "please enter 2 word"
read var1 var2
if [ "$var 1" = "$var2" ]; then
echo "These string are the same"
else
echo "the strings are different"
fi;
The if statement is coming out as false and it's printing the else echo. I looked on various sites and they say this is the format it should be. Am I making some syntax errors?
Solution
if [ "$var1" = "$var2" ]; then
(No space between $var and 1 in the condition.)
if [ "$var1" = "$var2" ]; thensee my answer below on how to useread." 1"clearly would be different from one of the words you typed, for example).