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 [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to