
正文
用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






![【电子书】[职业技术] 《Linux命令行与shell脚本编程大全(第3版)》[Richard Blum][epub+mobi+azw3] 【电子书】[职业技术] 《Linux命令行与shell脚本编程大全(第3版)》[Richard Blum][epub+mobi+azw3]](https://www.04ip.com/template/qe/style/noimg/9.jpg)
