Skip to main content

How to count the number of files in a directory

·45 words·1 min

How to count the number of files in a directory
#

Non recursive
#

find targetdir -type f -maxdepth 1 | wc -l 

Recursive
#

find targetdir -type f | wc -l 

Recursive and follow symlink #

find targetdir -type f -follow | wc -l