From owner-freebsd-questions Mon Dec 2 18:26:32 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 AC06B37B401 for ; Mon, 2 Dec 2002 18:26:30 -0800 (PST) Received: from english-breakfast.cloud9.net (english-breakfast.cloud9.net [168.100.1.9]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A51F43E88 for ; Mon, 2 Dec 2002 18:26:25 -0800 (PST) (envelope-from Hostmaster@Video2Video.Com) Received: from localhost (localhost [127.0.0.1]) by english-breakfast.cloud9.net (Postfix) with ESMTP id 8B14026E73; Mon, 2 Dec 2002 21:26:24 -0500 (EST) Received: from english-breakfast.cloud9.net (localhost [127.0.0.1]) by localhost (VaMailArmor-2.0.1.7) id 08198-712D7099; Mon, 02 Dec 2002 21:26:24 -0500 Received: from earl-grey.cloud9.net (earl-grey.cloud9.net [168.100.1.1]) by english-breakfast.cloud9.net (Postfix) with ESMTP id 5085026E55; Mon, 2 Dec 2002 21:26:24 -0500 (EST) Date: Mon, 2 Dec 2002 21:26:24 -0500 (EST) From: Peter Leftwich X-X-Sender: pete@earl-grey.cloud9.net To: Doug Hardie Cc: nkinkade@dsl-only.net, FreeBSD LIST Subject: Re: File Counts In-Reply-To: Message-ID: References: Organization: Video2Video Services - http://Www.Video2Video.Com MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.7; VAE: 6.16.0.0; VDF: 6.16.0.22; host: english-breakfast.cloud9.net) 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, 2 Dec 2002, Doug Hardie wrote: > Thanks to all who responded. The approach below does just what I needed. Here's another way I don't see listed: $ find . -type f | wc -l This means "find, starting right here, all files here and in subdirectories - then pipe the output through word count just the lines." You'd think FreeBSD would have a command similar to ls, df, du or a flag to the find command such as "-countitems" or something. > 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 > -- Doug -- Peter Leftwich President & Founder, Video2Video Services Box 13692, La Jolla, CA, 92039 USA http://Www.Video2Video.Com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message