24.15 Trimming a DirectoryIn article 4.7 , we mentioned that it's good to keep directories relatively small. Large directories can make your system seem slower because it takes more time to look up files. How small is "small"? Under 60 files is great. However, there's a problem: the size of a directory can only increase. That is, creating new files can make a directory bigger; deleting new files doesn't, in itself, make the directory any smaller. I'm not saying that a directory grows every time you create a new file. That's not true; if you've deleted a file, the directory will have an empty entry in it, and UNIX can re-use the empty entry. But the fact remains: a directory can only get bigger; it can never get smaller, unless you delete it. [Some BSD systems will "squeeze" directories smaller. -JP ] So let's say you've been sloppy and have a few directories around with hundreds of files, a lot of which is junk you don't need (I've been there). You could just delete the junk, which would make your disk happier, but you haven't reduced the directory's size. What do you do? Here's a trick:
- |
|