Article View: news.software.nntp
Article #19596Re: Quick way to list how many files in a each subdirectory?
From: brian moore
Date: Thu, 24 Jul 1997 00:00
Date: Thu, 24 Jul 1997 00:00
35 lines
2518 bytes
2518 bytes
In article <82pvs959be.fsf@manic.eecs.umich.edu>, Michael Hucka <hucka@eecs.umich.edu> writes: >>>>>> On 23 Jul 1997, bem@news.cmc.net (brian moore) wrote: > > bem> How about something like: > bem> find /var/spool/news -type d -size +24 -ls > > At least under Solaris 2.5.x, the size of the directory doesn't directly > correlate with the number of files in it. However, the size does appear to > increase monotonically with the number of files in the directory, so it's > true that you could use this as a rough guide to directory bloat (as Matt > Dillon also pointed out in a separate posting). True, and also true on any other *nix like system I know of. A directory entry is simply a pointer to an inode and the name of the entry. Of course since it's not a linked list, a directory of a hundred 100-byte filenames (roughly 10k) or two hundred 50-byte filenames (also roughly 10k) would take as long to search for a given file if strcmp's were free. (50 byte strcmps are assumed to be cheaper than 100 bytes, but that depends on your data distribution ... if the difference is usually in the first 50 bytes it won't matter much.) And since directories don't get smaller when you delete files, the size of the directory is still a factor even if there are no files listed in it. This is why the various hacks to get around the control/cancel directory structure do things like mv the directory and then rm it, or the better method of splitting the directory into pieces, effectively making it into a B-tree instead of the flat file it usually is. -- Brian Moore The opinions expressed above are my own, not Sysadmin, C/Perl Hacker necesarily my employers'.
Technical Details
Message-ID:
<5r6qbm$4$1@news.cmc.net>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mailReferences:
<823ep57gog.fsf@manic.eecs.umich.edu> <5r5qsr$qht$1@news.cmc.net> <82pvs959be.fsf@manic.eecs.umich.edu>Show Full Headers
Complete Article Headers
Message-ID: <5r6qbm$4$1@news.cmc.net> Subject: Re: Quick way to list how many files in a each subdirectory? Date: Thu, 24 Jul 1997 00:00:00 +0000 From: bem@news.cmc.net (brian moore) References: <823ep57gog.fsf@manic.eecs.umich.edu> <5r5qsr$qht$1@news.cmc.net> <82pvs959be.fsf@manic.eecs.umich.edu> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail X-Deja-AN: 258435161 Distribution: inet X-Complaints-To: abuse@cmc.net X-Trace: news.cmc.net 869723318 4 (None) 206.102.31.253 Organization: Chambers Multimedia Connection Reply-To: bem@news.cmc.net Newsgroups: news.software.nntp