I am using shell script to compare between 2 string varibles on whether are they blank. and run some action depending on which varibles are blank.
a=""
b=""
read a
read b
if [ -z $a ] && [ -n $b ] ;then
    echo "Var a is blank"
elif [ -n $a ] && [ -z $b ] ;then
    echo "Var b is blank"
elif [ -n $a ] && [ -n $b ] ; then
    echo "Both fields not empty"
else
    echo "Both fields are blank"
fi
I received binary operator expected error for the if else statements if my string varibles have spaces. What am I doing wrong? Please help.

