删除目录下(包括子目录)某天的文件

来源:互联网 发布:在淘宝开一个店多少钱 编辑:程序博客网 时间:2024/04/26 13:32
#!/bin/bashDATE10=$(date -d "10 days ago"  +%F)WEBPATH="/root/test/file"function rmLongerFile(){      fileInfo=$(stat $1 | grep -i 'Modify' | grep $DATE10)     if [ -z "$fileInfo" ];        then           echo $1"  [file date not match "$DATE10" not need remove]";        else           echo $1"  [file date match "$DATE10" should need remove]";           rm -rf $1     fi         }function findFile(){        for file in `ls $1`        do          if [ -d $1"/"$file ];          then                findFile $1"/"$file;              else                rmLongerFile $1"/"$file;                          fi        done}findFile $WEBPATH
0 0
原创粉丝点击