读书人

运用bash删除n天前的文件

发布时间: 2012-12-25 16:18:28 作者: rapoo

使用bash删除n天前的文件

#/bin/env bash## This script will remove the files created nDays days ago#nDays=30TARGET_PATH="/path/to/archive1:/path/to/archive2"SaveIFS=$IFSIFS=":"declare -a Array=($TARGET_PATH)IFS=$SaveIFSecho "`date` Arr Length="  ${#Array[@]}for i in "${Array[@]}" ; do  echo 'Remove ' $i  find $i -ctime +${nDays} -type f | xargs rm -fvdone


参考:http://rainbird.blog.51cto.com/211214/114362

读书人网 >编程

热点推荐