Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want a list of the folders from the current directory or one that I specify with their size.

I have tried with du but I only get the size of the directories I specify (du . ./f1), and ls doesn't show the size of the folders.

How do I do this without any scripting ?

share|improve this question
    
not to sound like a jerk, but 'man du' ;) –  Jakub Aug 3 '10 at 19:47
1  
Thanks ;-) but I've already tried and couldn't find anything. And try Googling du! –  kevin Aug 5 '10 at 6:39

4 Answers 4

up vote 21 down vote accepted

If you want to show all the directories in the current directory:

$ du -sh */
788K    foo/
500K    bar/
931K    baz/

To show them starting from another directory:

$ du -sh /path/to/dir/*/
48K     /path/to/dir/dir1/
4.0K    /path/to/dir/dir2/
6.7M    /path/to/dir/dir3/
20K     /path/to/dir/dir4/
8.0K    /path/to/dir/dir5/
44K     /path/to/dir/dir6/
share|improve this answer
    
Thanks all great answers but this one is the simplest one. I forgot the ending / in my tests. –  kevin Aug 5 '10 at 6:43

Another aproach is the --max-depth option.

du -h --max-depth=1 .

Will list all directories and files under the current folder with size.

Depth 2 would list one more level of folders.

share|improve this answer
    
On Mac, it's du -hd 2 . for 2 levels of depth. –  Ryan Aug 2 at 2:12
    
Ah yes. And probably on FreeBSD as well. Thanks for the info. –  matthias krull Aug 7 at 11:25

On a Mac, the --max-depth option is supplanted by -d [depth]. So, to see a human readable listing of your root drive plus 2 levels deep use the following:

du -hd 2 /* 

Note: this command will expose the top two directory levels off your root. This includes traversing one level into your Volumes, and will list the summary sizes of each top-level directory in each of your attached volumes. Depending on what you have attached, this command could take some time to complete.

share|improve this answer

Try:

$ du -s ./f1

or

$ du -sh ./f1

for more friendly readable sizes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.