So...
ls -l --block-size=MB
tells me that directory is one MB
ls -l --block-size=MB directory
tells me there's a 3MB file inside the directory. Shouldn't that make the directory at least 3MB? How can the directory be smaller than its contents?
So...
ls -l --block-size=MB
tells me that directory is one MB
ls -l --block-size=MB directory
tells me there's a 3MB file inside the directory. Shouldn't that make the directory at least 3MB? How can the directory be smaller than its contents?
No, because the contents of the first directory itself are only 1MB. If you want something that will sum all the sizes in the directory tree under a directory you want du
ls doesn't recurse into subdirectories as a normal matter of course. It just reports on the things that are directly in the location you are looking at. So in your first directory if you add up all the sizes of just the things directly in that directory it can be less than the sizes of the things in a subdirectory. But ls didn't look in that subdirectory, so doesn't know anything about them when it generates its listing for you.
du is apparently what I was expecting ls -l to give. I'll have to look up how to use du sometime as without any parameters the output isn't so great.
– alec
May 20 '15 at 01:57
ls you tried, du -sh is probably what you want. It will summarize all the subdirectory sizes into a single value, and make that human readable
– Eric Renouf
May 20 '15 at 02:01