#! /bin/bash # # Empty the trashcan, i.e., delete all files in $HOME/.trashcan # TRASH=$HOME/.trashcan # Make sure the trashcan exists: if [ -d $HOME/.trashcan ] ; then : else echo Creating $HOME/.trashcan mkdir $HOME/.trashcan # create a trashcan if needed chmod u=rwx $HOME/.trashcan chmod "go=" $HOME/.trashcan # hinder garbologists fi # Find the full pathname of the .trashcan: trashdir=`find $TRASH -prune -print` #function rm_maybe() { if [ "$1" != "$2" ] ; then rm -r "$2" ; fi ; } # This function will remove argument 2 unless it is also argument 1 # But I can't get find -exec to execute it, so put it in a separate # shell script: # find $TRASH -depth -exec rm_maybe $trashdir {} \; find $TRASH -depth -exec mtcan2 $trashdir {} \; exit