Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A shell script to remove old files prefixed with "temp_"
#!/bin/bash
# Trashes 'temp_*' files (that haven't been accessed in the past day)
# anywhere inside the home directory.
processFile() {
trash "$1" && echo "Trashed $1"
}
export -f processFile
# The ~/[A-Za-z]* pattern excludes dotfiles
find ~/[A-Za-z]* -name 'temp_*' -atime +0 -exec bash -c 'processFile "$0"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment