January 16, 2010

"du" with single level directory traversal

I always used du to know the size used up by the files in a particular directory, mostly recursively. But there were sometimes when I wanted to know the directory and file sizes upto only one level. May be "man du" would have helped, but as most *nix users are, I was lazy to do that. While reading a forum thread about the same question here, I came across the solution :

"du --max-depth=1"

and of course adding the "-h" switch would print the sizes in human readable form.