#!/bin/bash
DATE10=$(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
删除目录下(包括子目录)某天的文件
最新推荐文章于 2023-03-15 11:01:08 发布