shell脚本删除文件夹内上个月的文件
之前有脚本把日志转成excel,下个月开始删除上个月的
year=$(date -d "1 month ago" +"%Y")
month=$(date -d "1 month ago" +"%m")
folder="/usr/share/nginx/html/excel"
for file in `ls $folder`
do
if [ -d $folder"/"$file ]
then
find $folder"/"$file -name "$year-$month-*" -exec rm {} \;
fi
done

浙公网安备 33010602011771号