Date: Mon, 2 Dec 2002 12:58:49 -0800 (PST) From: Bill Schoolcraft <bill@wiliweld.com> To: freebsd-questions@FreeBSD.ORG Subject: Re: File Counts Message-ID: <Pine.LNX.4.44.0212021253090.25271-100000@corten8.billschoolcraft.com> In-Reply-To: <20021202200226.GJ467@sub21-156.member.dsl-only.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.LNX.4.44.0212021253090.25271-100000>