tags:

views:

301

answers:

2

I run the command unsuccessfully to get the size of directories (files inside belong to the size of a directory)

ls -lSrh

I get only kilobits for the size of directories while their content is more than that.

How can you list the size of directories including their content in the number by ls?

+9  A: 
du -sh directory_name

ls is going to give you the size of the directory entry, not of the directory contents. Based on my quick skim of man ls there doesn't appear to be a way to make ls dive down and calculate the size of the directories (most likely because it would be an expensive operation).

Sean Bright
And on any flavor of ls available on Windows (I checked Cygwin, GnuWin32, and MSYS), directories all have zero size. You don't even get to see the size of the list of directory entries as in (most?) *nix flavors.
RBerteig
I did not find an option to put the directories in order according to the size. How can you do that?
Masi
That's <http://stackoverflow.com/questions/586033/how-can-i-sort-du-h-output-by-size>
ashawley
du doesn't have such an option. You can pipe the output to "sort".
Andrew Medico
+1  A: 

If you want to get directories size, you can use

du -sh
Darth