#!/bin/sh # trashtrash - Deletes old files from ~/.Trash # License: 2007 Lenny Domnitser, all rights waived # Warranty: You're on your own read -p "O rly [y/N]? " really [ "$really" != "y" ] && exit 1 max_age=$((60 * 60 * 24 * 90)) # 90 days deleted=0 undeletable=0 for f in ~/.Trash/*; do age=$(($(date +%s) - $(stat -c %Y "$f"))) if [ $age -gt $max_age ]; then if rm -rfv "$f"; then deleted=$(($deleted+1)) else undeletable=$(($undeletable+1)) fi fi done echo "Deleted $deleted files and directories" if [ $undeletable ]; then echo "Could not delete $undeletable files and directories" exit 2 fi