How to count the number of files in a directory


I recently needed to count the number of files, not including directories, within a given directory. Additionally, I wanted to count recursively.

On FreeBSD or Linux, you can do this with the following commands:

$ find /path/to/dir -type f | wc -l

Pretty handy!

-Chris

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word