Created
March 20, 2012 22:12
-
-
Save fperez/2141793 to your computer and use it in GitHub Desktop.
dsize: compute directory size information
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/sh | |
# Script to summarize the sizes of files and subdirs in a given directory. | |
# If no arguments are given, the current directory is used. | |
# Modified after: http://www.newartisans.com/johnw/scripts/sizes | |
dir=${1:-.} | |
du -shx ${dir}/* ${dir}/.[a-zA-Z0-9_]* 2> /dev/null | \ | |
egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/sorted | |
egrep '^ *[0-9.]*M' /tmp/sorted | |
egrep '^ *[0-9.]*G' /tmp/sorted | |
rm /tmp/sorted | |
echo '-----------------------------------------------' | |
echo 'Total (including smaller dirs not shown above):' | |
du -shx $dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment