cleanup() { target=$1 for file in $(find $target -type f -name '*.tmp'); do rm $file done echo "cleaned $target" } cleanup "$1"