Bourne/bash shell scripts: string comparison
To determine if the value of a variable ($var) is empty (null):
if [ $var == "" ]
then
echo variable is null
fi
To determine if the value of a variable is not empty:
if [ $var != "" ]
then
echo variable is not null
fi
To compare the contents of a variable to a fixed string:
if [ $var == "value" ]
then
echo is the same
fi
To determine if variable’s contents are not equal to a fixed string:
if [ $var != "value" ]
then
echo not the same
fi





