From owner-freebsd-questions Mon Dec 2 12: 2:28 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 2122B37B401 for ; Mon, 2 Dec 2002 12:02:27 -0800 (PST) Received: from sub21-156.member.dsl-only.net (sub21-156.member.dsl-only.net [63.105.21.156]) by mx1.FreeBSD.org (Postfix) with ESMTP id A82FA43E9C for ; Mon, 2 Dec 2002 12:02:26 -0800 (PST) (envelope-from nkinkade@sub21-156.member.dsl-only.net) Received: from nkinkade by sub21-156.member.dsl-only.net with local (Exim 4.10) id 18Iwlu-00013q-00 for freebsd-questions@freebsd.org; Mon, 02 Dec 2002 12:02:26 -0800 Date: Mon, 2 Dec 2002 12:02:26 -0800 From: Nathan Kinkade To: freebsd-questions@freebsd.org Subject: Re: File Counts Message-ID: <20021202200226.GJ467@sub21-156.member.dsl-only.net> Reply-To: nkinkade@dsl-only.net Mail-Followup-To: freebsd-questions@freebsd.org References: <7026DC6B-0622-11D7-B566-000393681B06@lafn.org> <002301c29a3a$f38733e0$ca0110ac@vinyl.tkvbp.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <002301c29a3a$f38733e0$ca0110ac@vinyl.tkvbp.com> User-Agent: Mutt/1.4i 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 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 There is probably a better way to do this. Nathan To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message