How can i comparing string's whith blank spaces?
I have this problem:
DIF1="STRING 1212"
DIF2="STRING 1212"
if [ ${DIF1} != ${DIF2} ]
then
echo "Differents"
else
echo "Equals"
fi
Error:
1212}: unknown test operator
Thanks!
How can i comparing string's whith blank spaces?
I have this problem:
DIF1="STRING 1212"
DIF2="STRING 1212"
if [ ${DIF1} != ${DIF2} ]
then
echo "Differents"
else
echo "Equals"
fi
Error:
1212}: unknown test operator
Thanks!
Wrap them in double quotes:
if [ "${DIF1}" != "${DIF2}" ]
Thanks!!
i think you will need to quote them in your if statement thus:-
if [ "${DIF1}" != "${DIF2}" ]
I hope that this helps.
Robin
Liverpool/Blackburn
UK