Last active
September 3, 2015 14:34
-
-
Save mcorsen/f9fd04565771da347021 to your computer and use it in GitHub Desktop.
Clean old log files and directories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ $# -lt 3 ]] | |
then | |
echo "Usage: $0: <dir> <file pattern> <num days old>" | |
exit 1 | |
fi | |
dir=$1 | |
file_pattern=$2 | |
num_days=$3 | |
find ${dir} -maxdepth 1 -name "${file_pattern}" -mtime +${num_days} | xargs -I {} bash -c 'echo "Removing {}"; rm -rf {};' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment