Monday, July 16, 2007

a tree view of directories

Working in a production environment, we often need to find out which directories take up all space. At first, I was using the command df -k . | sort -u but the output is not very easy to look at. I decided to create a small perl script that would display the size of all the directories in the current location. Here is an exemple :

<img width='450' height='379' border='0' hspace='5' src='/blog/uploads/jbdu01.gif' alt='' />

You can also call the script with a depth argument. If you want to have the size of 2 subdir levels (current level and one sub level), call the script with 2 :

<img width='499' height='464' border='0' hspace='5' src='/blog/uploads/jbdu02.gif' alt='' />


This is a very simple script but it helps me a lot. That's why I decided to publish it on my blog. Use it as you wish !!! It works as is on Linux (Fedora core 3 and 4), AIX 4.X and 5.X, and Solaris 8 and 9.

<a href="/blog/uploads/jbdu" title="jbdu" target="_blank">You can download the code from here.