用shell脚本写出检测/tmp/size.log文件,如果存在显示它的内容,不存在则创建一个文件将创建时间写入

Posted fanren224

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用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

 

以上是关于用shell脚本写出检测/tmp/size.log文件,如果存在显示它的内容,不存在则创建一个文件将创建时间写入的主要内容,如果未能解决你的问题,请参考以下文章