The goal is to quickly count all the files that exist in a given folder (recursively).
find <path> -type f | wc -l
If you don't want to recurse down into all the sub-folders, the command can be tweaked to:
find <path> -type f -depth 1 | wc -l
The same logic can be used to count directories, simply replace the -type f
with -type d
. Or remove it entirely to count both.
find <path> -type d -depth 1 | wc -l