Skip to content

Instantly share code, notes, and snippets.

@codrcodz
Last active June 20, 2017 17:43
Show Gist options
  • Save codrcodz/b642289539c28fd41ddc444db59f394e to your computer and use it in GitHub Desktop.
Save codrcodz/b642289539c28fd41ddc444db59f394e to your computer and use it in GitHub Desktop.
Shell script for generic Linux systems. Used to quickly find large files on the file system based on common large file extensions.
nlvl=-20; \
printf "MB\tDirectory Name\n"; \
nice -n ${nlvl} \
find / \
-type f \
-regextype egrep \
-regex ".*\.(gz$|iso$|sql$|bak$|zip$|log$|tar$|csv$|tgz$|mp4$|png$|xz$)" \
-exec dirname '{}' \; \
| sort -u \
| while read dir; do \
nice -n ${nlvl} du -m $dir; \
done 2>&1 \
| sort -nr \
| head -n 20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment