b1=
b2=""
b3="hello"
if [[ -n "${b3}" ]]
then
    echo "not null"
else
    echo "null"
fi

b1     null

b2     null

b3     not null

 

-n str   字符串长度非零

相关文章: