From owner-freebsd-questions Fri Dec 10 9:56:39 1999 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id A8B0514A10 for ; Fri, 10 Dec 1999 09:56:36 -0800 (PST) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.9.3) id MAA63373; Fri, 10 Dec 1999 12:59:31 -0500 (EST) (envelope-from cjc) From: "Crist J. Clark" Message-Id: <199912101759.MAA63373@cc942873-a.ewndsr1.nj.home.com> Subject: Re: hopefully three simple questions In-Reply-To: from Zhihui Zhang at "Dec 10, 1999 07:40:03 am" To: zzhang@cs.binghamton.edu (Zhihui Zhang) Date: Fri, 10 Dec 1999 12:59:31 -0500 (EST) Cc: dnelson@emsphone.com (Dan Nelson), ben@scientia.demon.co.uk (Ben Smithurst), cjclark@home.com, freebsd-questions@FreeBSD.ORG Reply-To: cjclark@home.com X-Mailer: ELM [version 2.4ME+ PL54 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Zhihui Zhang wrote, > > On Thu, 9 Dec 1999, Dan Nelson wrote: > > > In the last episode (Dec 09), Zhihui Zhang said: > > > On Thu, 9 Dec 1999, Ben Smithurst wrote: > > > > Crist J. Clark wrote: > > > > > Zhihui Zhang wrote, > > > > > > > > > >> (2) How to find the largest directory in a filesystem? I mean > > > > >> the one with the maximum number of files in it. > > > > > > I have found a solution (hopefully correct): > > > > > > # find / -type d -ls | awd '{print $2, $11}' | sort -n | tail > > > > > > -Zhihui > > > > The "size" of the directory printed by 'find' does not always indicate > > how many files are in it. If you fill a directory with files and then > > delete every other file, it won't be able to compact out the empty > > slots. You'll have to walk the entire directory tree and count the > > files in each subdirectory, I'm afraid. > > > Yes! If you do a rm * under a directory, the directory size remains the > same until next time you do a lookup operation on it. It is a good point! An even better point is that the size of the directory is also a function of the length of the filenames it holds. For example, % mkdir test1 test2 % touch test1/{00,01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19} % touch test2/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA{0,1,2,3,5} % ls -A test1 | wc -l 20 % ls -A test2 | wc -l 5 % ls -ld test? drwxrwxr-x 2 cjc staff 512 Dec 10 12:48 test1 drwxrwxr-x 2 cjc staff 1024 Dec 10 12:49 test2 Even though test2 has fewer files, it's bigger. -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message