From owner-freebsd-questions Mon Dec 2 16: 4:29 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 D6DED37B401 for ; Mon, 2 Dec 2002 16:04:27 -0800 (PST) Received: from zoon.lafn.org (zoon.lafn.org [206.117.18.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 65BEA43ECF for ; Mon, 2 Dec 2002 16:04:27 -0800 (PST) (envelope-from bc979@lafn.org) Received: from lafn.org (host-66-81-198-118.rev.o1.com [66.81.198.118]) by zoon.lafn.org (8.12.3/8.11.3) with ESMTP id gB304Fbv064074; Mon, 2 Dec 2002 16:04:16 -0800 (PST) (envelope-from bc979@lafn.org) Date: Mon, 2 Dec 2002 16:04:14 -0800 Subject: Re: File Counts Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v548) Cc: freebsd-questions@FreeBSD.ORG To: nkinkade@dsl-only.net From: Doug Hardie In-Reply-To: <20021202200226.GJ467@sub21-156.member.dsl-only.net> Message-Id: Content-Transfer-Encoding: 7bit X-Mailer: Apple Mail (2.548) 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 Thanks to all who responded. The approach below does just what I needed. On Monday, Dec 2, 2002, at 12:02 US/Pacific, Nathan Kinkade wrote: > 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 > > -- Doug To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message