#!/bin/bash # script will change the expiration date of the all backups for a bank # that are older than time specified # -b bank-name # -a age # age is number of days like 45 or 90 # -l (just list the changes that would be amde) BANK='' ((AGE=180)) DISPLAY_ONLY='no' # grab parameters while [ "X$1" != "X" ] do case $1 in # bank option '-b' ) shift BANK="$1" ;; # age option '-a' ) shift tmp="$1" ((AGE = tmp + 0)) ;; # display only option '-l' ) DISPLAY_ONLY='yes' ;; # Usage * ) echo "Usage: $0 -b -a [-l]" echo " bank-path -- path to bank" echo " days -- numbers that trees older than that will be marked as expired" echo " -l -- code only displays which trees it would change" exit esac shift done cd $BANK || (echo "Warning: Cannot cd into $BANK"; exit 1) for dir in 2* do cd $dir dt=$(cat summary | grep Expire: | awk -F '=' '{print $3}') CurrentExpire=$(date --utc --date "$dt" "+%Y-%j") MaxExpire=$(date "+%Y-%j" -d "-${AGE} days") if [[ $MaxExpire > $CurrentExpire done