1. 判断目录不存在
dir="directory"
if [ ! -d $dir ]; then
echo "$dir not exist"
fi
2. 判断目录为空
dir="directory"
if [ "$(ls -A $dir)" == "" ]; then
echo "$dir is empty"
fi
3. 判断文件存在
file="script"
if [ -f $file ]; then
echo "$file exist"
fi
4. 判断字符串为空
if [ -z "$var" ]; then
echo "string empty"
fi
5. 判断真假
var=true
if [ $var ]; then
echo "var is true"
fi