Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Dec 2002 16:04:14 -0800
From:      Doug Hardie <bc979@lafn.org>
To:        nkinkade@dsl-only.net
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: File Counts
Message-ID:  <C21B13C8-0652-11D7-B566-000393681B06@lafn.org>
In-Reply-To: <20021202200226.GJ467@sub21-156.member.dsl-only.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?C21B13C8-0652-11D7-B566-000393681B06>