shell check variable empty string code example
Example 1: bash check if variable is empty
if [ -z "$var" ] #return true if $var is unset
Example 2: bash script check empty string
if [ -z "$var" ]
then
echo "\$var is empty"
else
echo "\$var is NOT empty"
fi