#!/bin/bash # --------------------------------------------------- root_dir=/opt/store/cvtt/eqt_hist_md prune_criteria="6 month ago" oldest=$(date -d "${prune_criteria}" '+%Y-%m-%d') find_cmd="find ${root_dir}/ '(' -name '*.zip' ')' -type f -not -newermt ${oldest}" echo ${find_cmd} files=$(eval $find_cmd) if [ "$files" == "" ] then echo "No .zip files found older than ${prune_criteria} (${oldest}) in ${root_dir}" else duf ${root_dir} echo "Removing files older than ${prune_criteria} (${oldest})" echo $files rm $files duf ${root_dir} fi echo "${0} Done...."