bash check variable is empty code example
Example 1: bash if variable is not empty
VAR=`echo Hello world`
if [[ -n "$VAR" ]] ; then echo "Variable is set" ; fi
Example 2: bash script check empty string
if [ -z "$var" ]
then
echo "\$var is empty"
else
echo "\$var is NOT empty"
fi