GotchaCode

Need Human Readable Disk Usage Stats,Add This Script

11 Dec 2011

If you want a more human readable Disk Usage stats while using linux, add the following script to your .bashrc
alias duf='du -sk * | sort -n | perl -ne '\''($s,$f)=split(m{\t});for (qw(K M G)) {if($s<1024) {printf("%.1f",$s);print "$_\t$f"; last};$s=$s/1024}'\'

You should add it under User specified Functions and aliases. When you are done with it this is what you will see when you type duf in your terminal.

This is nice, but how about using the -h option to du?

$ du -sh *
17M bugzilla-3.4.6
36K hsperfdata_root
52M new
42M old
0 sfcbLocalSocket
4.0K ssh-ffOOT30605

Could you remove the line in my message labelled "mapping" (thanks!).

Tweet