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.