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

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

VAR=

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

    echo "var is null"

fi

猜你喜欢

转载自zzuwxf.iteye.com/blog/1407000