Tuesday 20 October 2009

How to get directory size in Unix shell?

It turns out that finding the size of a directory via shell / command line on a Unix based machine is not 'that' straight forward. Thanks to Dr. Google again...I was able to find the solution (by some kind person who posted the solution on their blog!).
 du -sh dir_name

The '-s' tells du to only return entries only from the specified directory
The '-h' makes du return something human readable

Very useful indeed! : D

Ref: http://stevejamesson.com/2008/06/18/unix-get-full-size-of-directory-folder