shell中判断字符串null值
if [ -n "$str1" ]; then
echo "$str1 is NOT null"
fi[ ${#str1} -eq 0 ] && echo "str1:Null"
[ _${str1} = _ ] && echo "str1:Null"参考
Last updated
if [ -n "$str1" ]; then
echo "$str1 is NOT null"
fi[ ${#str1} -eq 0 ] && echo "str1:Null"
[ _${str1} = _ ] && echo "str1:Null"Last updated