Skip to content

Instantly share code, notes, and snippets.

@fperez
Created March 20, 2012 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fperez/2141793 to your computer and use it in GitHub Desktop.
Save fperez/2141793 to your computer and use it in GitHub Desktop.
dsize: compute directory size information
#!/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