判断shell变量是否空字符串
#!/bin/sh
STRING=
if [ -z "$STRING" ]; then
echo "STRING is empty"
fi
if [ -n "$STRING" ]; then
echo "STRING is not empty"
filine 71: [: too many arguments#!/bin/sh
STRING=
if [ -z $STRING ]; then
echo "STRING is empty"
fi
if [ -n $STRING ]; then
echo "STRING is not empty"
fi参考
Last updated