I need to compare a to z.
if[$a -eq $z]
then echo "something"
else echo "nothing"
fi
What is wrong with this code?
I need to compare a to z.
if[$a -eq $z]
then echo "something"
else echo "nothing"
fi
What is wrong with this code?
You need spaces to separate [
from the if
command, and to separate it from its arguments.
if [ "$a" -eq "$z" ]
Note also that -eq
is for comparing numeric values. If the variables contain strings, you should use =
.