Skip to content

Instantly share code, notes, and snippets.

@rushipkar90
Created September 25, 2015 16:34
Show Gist options
  • Save rushipkar90/a33db28064a71ae8264b to your computer and use it in GitHub Desktop.
Save rushipkar90/a33db28064a71ae8264b to your computer and use it in GitHub Desktop.
findextensions.sh
#!/bin/sh
# Directory to store log files in
DST=/root/logs
# Any logs older than this will be deleted first
KEEPDAYS=14
# Create DST if it doesn't exist
if [ ! -d "$DST" ]; then
mkdir $DST
fi
# Remove logs older than KEEPDAYS in DST
find ${DST} -type f -mtime +${KEEPDAYS} -exec rm -f {} \;
# Find files over 150MB
find /home -iname \*.mp3 -o -iname \*.mp4 -o -iname \*.avi -o -iname \*.mpg -o -iname \*.flv -o -iname -o -iname \*.iso -o -iname \*.rar -o -iname \*.mpeg > ${DST}/files_bad_extensions-`date +%F`.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment