From owner-freebsd-questions Mon Dec 2 12:42:42 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C941E37B401 for ; Mon, 2 Dec 2002 12:42:39 -0800 (PST) Received: from corten2.billschoolcraft.com (adsl-63-193-247-201.dsl.snfc21.pacbell.net [63.193.247.201]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2422B43EC5 for ; Mon, 2 Dec 2002 12:42:39 -0800 (PST) (envelope-from bill@wiliweld.com) Received: from corten8.billschoolcraft.com ([192.168.7.8] helo=corten8) by corten2.billschoolcraft.com with esmtp (Exim 3.22 #1 (Debian)) id 18IxOn-00012m-00 for ; Mon, 02 Dec 2002 12:42:37 -0800 Date: Mon, 2 Dec 2002 12:58:49 -0800 (PST) From: Bill Schoolcraft X-X-Sender: bill@corten8.billschoolcraft.com To: freebsd-questions@FreeBSD.ORG Subject: Re: File Counts In-Reply-To: <20021202200226.GJ467@sub21-156.member.dsl-only.net> Message-ID: System-ID: [en] (I; Linux i86pc) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At Mon, 2 Dec 2002 it looks like Nathan Kinkade composed: > On Mon, Dec 02, 2002 at 02:42:28PM -0500, Kliment Andreev wrote: > > > How do I get a count of the files in directories? I need to be able to > > > get a listing of the number of files in a directory and counts for the > > > files in each sub-directory. > > > > % ls -l | wc -l (In a directory) > > % ls -lR | wc -l (Including sub-directories) > > Or, if you are looking for subtotals, something close to this might be > helpful. Beware that this will include a count for the "." and ".." > entries. > > $ for dir in `find . -type d`; do echo $dir ; ls -l $dir | wc -l; done > ls -alR | grep ^- | wc -l That should show you just the "files" and not the directories but not any symbolic links, to show the symlinks too I'd probably try: ls -alR | grep ^[-l] | wc -l And last but not least, only the directories: ls -alR | grep ^d | wc -l Hope that helps a little. -- |<----------------------"Word-Wrap-At-72-Please"---------------------->| Bill Schoolcraft PO Box 210076 -o) San Francisco CA 94121 /\ "UNIX, A Way Of Life." _\_v To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message