shell中测试一个变量是不是为空

shell中测试一个变量是否为空

来看下面的例子,注意双引号是必不可少的。

 

VAR=

 

if [[ -z "$VAR" && "$VAR" = ''  ]]; then

    echo "var is null"

fi