使用bash删除n天前的文件

#/bin/env bash
#
# This script will remove the files created nDays days ago
#

nDays=30
TARGET_PATH="/path/to/archive1:/path/to/archive2"

SaveIFS=$IFS
IFS=":"
declare -a Array=($TARGET_PATH)
IFS=$SaveIFS

echo "`date` Arr Length="  ${#Array[@]}
for i in "${Array[@]}" ; do
  echo 'Remove ' $i
  find $i -ctime +${nDays} -type f | xargs rm -fv
done


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

你可能感兴趣的:(bash,script)