Counting the number of files in a directory from a Linux command line is easy. The following command will return the number of files in the current directory and all subdirectories:
$> find directory_name -type f -follow | wc -l
This will count all files and files in subdirectories, but not the subdirectories themselves. To find all the files in only the current directory, you can use:
$> find directory_name -type f -maxdepth 1 -follow | wc -l
If you would like to count subdirectories, simply remove the -type flag.




