首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

运用bash删除n天前的文件

2012-12-25 
使用bash删除n天前的文件#/bin/env bash## This script will remove the files created nDays days ago#nD

使用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

热点排行