(General Question) how to count how many files in a directory tree

Rod Haper rhaper at houston.rr.com
Sun May 16 19:15:23 UTC 2004


Craig Tinson wrote:
> Quick question for you smart bods out there
> 
> I know that "ls -1 | wc -l" will tell me how many files there are in the 
> current directory..
> 
> how would I go about finding out how many files there are in the current 
> directory *and* it's sub directories?
> 
> TIA
> 
> Craig
> *
> *
> 


If you want to count only files in the current directory and all 
subdirectories, try this:

find . -type f -print | wc -l

Btw, the method you used in your email above skips dot (.*) files and 
includes directories, links, fifos, etc.  If you don't care about that, 
just add the -R or --recursive switch to your ls command.





More information about the fedora-list mailing list