This post will show you how to count files under a Linux directory.
Step 1: cd to the folder you would like to count the files.
Step 2: issue the following command, then you should see a number, which is the number count of the files under the current directory.
find . -type f | wc -l
-type findicates counting files only. You can remove the
-type fto include directories (and symlinks) while counting.
findcommand’s standard output to
wccommand’s standard input.
wc(stands for word count) counts newlines, words, and bytes on its input (see here for more details.).
-lto count just newlines.
- This command may overcount if filenames can contain newline characters.