如题所述
1、if语句判断
-s filename 如果 filename存在不为空,则为真
[ -s /var/log/syslog ] 取反存在且为空[ ! -s /var/log/syslog ]
2、例如
#!/bin/sh
file=~/a.txt
if [ ! -s $file ];then
echo $file is a blank file
else
echo $file is not a blank file
fi
-s filename 如果 filename存在不为空,则为真
[ -s /var/log/syslog ] 取反存在且为空[ ! -s /var/log/syslog ]
2、例如
#!/bin/sh
file=~/a.txt
if [ ! -s $file ];then
echo $file is a blank file
else
echo $file is not a blank file
fi
温馨提示:答案为网友推荐,仅供参考