Last active
December 11, 2016 23:07
-
-
Save indrayam/f801b6f3881b3ccf40b272a92a2079e8 to your computer and use it in GitHub Desktop.
Unix command to find the top 10 files and folders recursively inside a Unix folder
This file contains hidden or 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
# These commands will ONLY work if you are using GNU 'du', 'find' and 'sort' commands | |
# Top 10 files by recursively diving inside the current folder (skip .git and .svn folders) | |
find . -type d \( -iregex ".*git" -o -iregex ".*svn" \) -prune -o -type f -exec du -Sh {} + | sort -rh | head -n 10 | |
# Top 10 files by recursively diving inside the current folder (without skipping any folders) | |
find . -type f -exec du -Sh {} + | sort -rh | head -n 10 | |
# Top 10 directories by recursively diving inside the current folder (skip .git and .svn folders) | |
du -Sh --exclude=".git" --exclude=".svn" | sort -rh | head -n 10 | |
# Top 10 directories by recursively diving inside the current folder (without skipping any folders) | |
du -Sh | sort -rh | head -n 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment