This small shell script will turn the default Mac du into the more user-friendly GNU du -h variant. The -h flag stands for "human readable" and instead of du telling you that a given folder uses "4628" 1024-byte blocks, you'll see that it uses "4.6M" (for Megabytes). To add this human readable format to the existing du, make a shell script called duh.sh with the following code:
# Make du -k into du -h
#
du -k $1 $2 $3 $4 | awk '{if($1>1024){r=$1%1024;if(r!=0)
{sz=($1-r)/1024}else{sz=$1/1024}print sz"Mt"$2;}
else{print $1"Kt"$2}}'
#
# End Code
The three lines starting with du -k $1 $2... should be entered as one long line with no additional spaces other than what's already shown. Don't forget to set the perms to execute by typing chmod a+x duh.sh. Now you can just use duh.sh in place of du. To make life even better, you can alias duh.sh to du to replace the stock command:
% alias du=`duh.sh`[robg adds: I wrote a hint a couple of years back that explained how to install a subset of the GNU disk utilities, including the humand-readable forms of both du and df. This hint accomplishes much the same result without installing any new software.]
Mac OS X Hints
http://hints.macworld.com/article.php?story=20030625115813660