Count all files in a directory, recursively

Count files in current folder, not recursive:

ls -1 | wc -l

Count files only:

find . -type f | wc -l

Count files and directories:

find . | wc -l

Count directories only:

find . -type d | wc -l

Now look at this:

~/.nuget$ find . -type f | wc -l
~/.nuget$ find . | wc -l

The .nuget folder has 5259 files. Even worse... it has almost as many directories as folders!


See also