用shell脚本写出检测/tmp/size.log文件,如果存在显示它的内容,不存在则创建一个文件将创建时间写入
1 #!/bin/bash 2 if [ -d "/tmp" ]; then 3 echo "/tmp is exists" 4 else 5 mkdir /tmp 6 fi 7 if [ -f "/tmp/size.log" ]; then 8 echo "size.log is exist";cat /tmp/size.log 9 else 10 touch /tmp/size.log; date > /tmp/size.log; echo "date has been successfully written to size.log" 11 fi