shell腳本(刪除7天以前的文件)

#!/bin/bash
#########################
#刪除7天以前的文件      #
#2019年6月15日18:12:26  #
#########################
path=/opt/teach/shell/project/test/
find $path -type f  -mtime +7 | xargs rm -rvf
#find $path -type f -mtime +3 -exec rm -rvf {} \;
#這裏的{} 其實是將前面的結果套進去使用 \換行 ;結束一條命令 xargs以空格爲定界符


#find常規用法
#find path -option -exec shll
#找到名稱以test開頭的文件,而且列出大小
#find /opt -name "test*" -type f -exec ls -lh {} \;
#找到3天以前的文件
find /opt -mtime +3
#找到3天之內的文件
find /opt -mtime -3
#找到3天以上4天之內的文件
find /opt -mtime 3
#找到大小超過15M的文件
find /opt -size 15m -type f
相關文章
相關標籤/搜索