Possible Duplicate:
When running ls -l, why does the fil开发者_如何转开发esize on a directory not match the output of du?
Hi. I'm interesting in information what show me output ls -la in linux. So, default size is 4K. But if there are a lot of files, maybe with zero size, such as PHP sessions =), the size != 4K. What showing me ls -la? And after, when i clean this folder i see tha last max size.
ls -al
will give you the space taken up by the directory itself, not the files within it.
As such, it has a minimum size. When a directory is created, it's given this much space to store file information which is a set number of bytes per file (let's say 64 bytes thought the number could be different).
If the initial size was 4K, that would allow up to 64 files. Once you put more than 64 files into the directory, it would have to be expanded.
As for your comment:
The reason why it may not get smaller when you delete all the files in it is because there's usually no real advantage. It's just left at the same size so that it doesn't have to be expanded again next time you put a bucketload of files in there (it tends to assume that past behaviour is an indicator of future behaviour).
If you want to reduce the space taken, there's an old trick for doing that. To reduce the size of /tmp/qq
, create a brand new /tmp/qq2
, copy all the files across (after deleting those you don't need), then simply rename /tmp/qq
to /tmp/qq3
and /tmp/qq2
to /tmp/qq
. Voila! Oh yeah, eventually delete /tmp/qq2
.
精彩评论