Get the Number of Files in a Directory

Last modified: 
Wednesday, December 16th, 2015

How to find the number of files in a directory using the command line in linux or OS X.

List the total number of files but not directories, recursively

find . -type f | wc -l

List the number of files and directories in the target directory

ls -1 targetdir | wc -l 

The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.