This shell script is used to show me how much space a particular directory takes up. The idea came to me while I was looking at filelight at one point because I was wondering hot much space some directories are taking on one of my systems. I could see the space used by a directory (and all it's subdirectories), but I wanted a way to see that space usage from the command line as well. Maybe someone had already written it, but this was my first pass at it back in 2005.
#! /bin/sh echo du $DIR --max-depth=1 -k 2>/dev/null
Then I made some improvments so I could run it against either my current directory or against a path I had permissions to, giving me the current version below:
#! /bin/sh DIR=$1 if [ -z $1 ]; then DIR=. fi echo -n "Displaying size of: " if [ $DIR = "." ]; then echo `pwd` else echo "$DIR" fi echo -e '\n' du $DIR --max-depth=1 -k 2>/dev/null
I'm sure further improvements could be made, but this gives me a quick view of the space used. Sometimes I use this with space.sh | sort -n to sort my directories in numerical order so I can easily see which are the largest subdirectories.