[Gllug] # files in a subdir

tet at accucard.com tet at accucard.com
Fri Sep 21 07:54:57 UTC 2001


>but if I wanted to find the *number of files* in each subdirectory, how
>would I do that?
>
>I could use du -a | wc for each subdirectory, but I was wondering if
>there was a neater way than listing each file and wc'ing it?

You could use:

	find . -type f -print | wc -l

to find out how many files are under a given directory, or:

	find . -print | wc -l

to find and how many files and directories are there. For large
directory trees, both of these will be faster than using du because
it doesn't have to stat each file.

Tet

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list