kmorris511 kmorris511 - 1 year ago 101
Linux Question

Using ls to list directories and their total sizes

Is it possible to use

in Unix to list the total size of a sub-directory and all its contents as opposed to the usual 4K that (I assume) is just the directory file itself? I.E.

total 12K
drwxrwxr-x 6 *** *** 4.0K 2009-06-19 10:10 branches
drwxrwxr-x 13 *** *** 4.0K 2009-06-19 10:52 tags
drwxrwxr-x 16 *** *** 4.0K 2009-06-19 10:02 trunk

After scouring the man pages I'm coming up empty.

Answer Source

Try something like:

du -sh *


du: Disk Usage

-s: Display an entry for each specified file. (Equivalent to -d 0)

-h: "Human-readable" output. Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download