bash check 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
Example 3: shell cehck if string is null
my_var="nixCraft"
if [ -z "$my_var" ]
then
echo "\$my_var is NULL"
else
echo "\$my_var is NOT NULL"
fi
// https://www.cyberciti.biz/faq/bash-shell-find-out-if-a-variable-has-null-value-or-not/