Is it possible to use ls
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?
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.
Using the ls Command–l – displays a list of files and directories in long format and shows the sizes in bytes. –h – scales file sizes and directory sizes into KB, MB, GB, or TB when the file or directory size is larger than 1024 bytes. –s – displays a list of the files and directories and shows the sizes in blocks.
Open a file explorer window and right-click on the 'Name' field at the top. You'll see some options – specifically, options, that let you pick what sort of info you want to see about your folders. Select Size and the property will appear on the far right of your window.
To get the total size of a directory in Linux, you can use the du (disk-usage) command.
Try something like:
du -sh *
short version of:
du --summarize --human-readable *
du
: Disk Usage
-s
: Display a summary for each specified file. (Equivalent to -d 0
)
-h
: "Human-readable" output. Use unit suffixes: Byte, Kibibyte (KiB), Mebibyte (MiB), Gibibyte (GiB), Tebibyte (TiB) and Pebibyte (PiB). (BASE2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With