HI all,
I wrote this code but it doesn’t catch any of the two variables being null, why?
echo "$var1 - $var2"
if [ "$var1" == ""] || [ "$var2" == ""]
then
echo "Incomplete data"
exit 1
fi
The initial echo prints nothing for the variables when I run my script so the if statement should work right? But it doesn’t for some reason.
||has a different meaning in the shell. Also==is not used for comparison;=is. Maybe you meant:Quoting from the manpage:
EXPRESSION1 -o EXPRESSION2 either EXPRESSION1 or EXPRESSION2 is true -z STRING the length of STRING is zero