linux count files in directory recursive code example

Example 1: count files recursively linux

find DIR_NAME -type f | wc -l

Example 2: how to check how many files are in a folder linux

$ ls | wc -l

Example 3: how to count all files in a directory linux recursively

find DIR_NAME -type f | wc -l

Example 4: bash count files in directory recursively matchingattern

ls -Uba1 | grep ^log | wc -l

Example 5: bash count files in directory recursively matchingattern

find . -type f -name '*.log' -printf x | wc -c