sh 空文件判断

1.用-s判断时间是否为NULL

###############################

echo "Begin to check file"

#for i in `ls *|awk -F '.' '{print $1}'` //获取文件名(不带后缀)

#获取循环获取文件名

for i in `ls *`

do

#echo $i

if [ ! -s $i ];then

echo "The file of [$i] is null."

fi

done

echo "Complete!!!" exit 0

################################

 

2..用-s判断时间是否为NULL

###############################

echo "Begin to check file"

#for i in `ls *|awk -F '.' '{print $1}'` //获取文件名(不带后缀)

#获取循环获取文件名

for i in `ls *`

do

#echo $i

if [ ` ls -l i| awk '{print $5}' ` -eq 0 ];
then echo '==' ;
else echo '!=';
fi

if [ ! -s $i ];then

echo "The file of [$i] is null."

fi

 

done

echo "Complete!!!" exit 0

################################

posted @ 2016-05-04 16:50  小菜77  阅读(342)  评论(0编辑  收藏  举报