[wplug] disk usage

Zach netrek at gmail.com
Mon Mar 31 16:52:09 EST 2008


I am looking for a recursive script (SH/BASH/Perl) which will show the
total size (in MB) of each all subdirectories in a given directory. I
would like this sorted with the largest ones listed at the top. Also a
second script to show the largest files (also in MB and sorted with
biggest at the top) and show which directory it is in.

First script:

$test> ls

test1/ test2/ test3/

$test3> ls

testsub/

First script would produce something like:
30MB test3/
20MB test2/
10MB test1/
  5MB test3/testsub/

$test1> ls

-rw------- 1 ubuntu ubuntu   20468 2008-03-29 21:17 foo

$test2> ls

-rw------- 1 ubuntu ubuntu   10231 2008-03-29 20:03 bar

$test3/testsub> ls

-rw------- 1 ubuntu ubuntu     5303 2008-03-29 21:17 baz


And the second script would produce:

20MB test1/foo
10MB test2/bar
  5MB test3/testsub/baz

Zach


More information about the wplug mailing list