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


猜你喜欢

转载自blog.51cto.com/13760226/2414514
今日推荐