标签:exist 输出 txt code root 清空文件 日志 int The
#!/bin/bashFILE=/root/hello.txt
#判断文件是否存在
if ! [ -f $FILE ]
then
#输出文件不存在
echo "file not exist!"
exit 1
fi
#判断文件大小,ls -l 用awk取输出的第五列
if [ ls -l $FILE|awk ‘{print $5}‘
-gt $((1024*1024)) ]
then
#输出空到文件中
echo " "> $FILE
fi
标签:exist 输出 txt code root 清空文件 日志 int The
原文地址:https://blog.51cto.com/2225052/2356086