a="a"
b="a"
if [ $a = $b ]
then
echo "="
else
echo "!="
fi
#-z 检查str1的长度是否为0
if [ -z $a ]
then
echo "zero"
else
echo "not zero"
fi
#-n 检查str1的长度是否非0,注意需加""
c=""
if [ -n "$c" ]
then
echo "not zero"
else
echo "zero"
fi
=
not zero
zero
shell判空
最新推荐文章于 2024-06-07 10:36:27 发布