linux中判断变量是否为空 -z选项
1、
root@DESKTOP-1N42TVH:/home/test# echo $a root@DESKTOP-1N42TVH:/home/test# [ -z $a ] && echo "null" || echo "no null" ## -z判断变量是否为空,空返回TRUE,非空返回FALSE null root@DESKTOP-1N42TVH:/home/test# a=100 root@DESKTOP-1N42TVH:/home/test# echo $a 100 root@DESKTOP-1N42TVH:/home/test# [ -z $a ] && echo "null" || echo "no null" ## 非空返回FALSE no null

浙公网安备 33010602011771号