HOWTO: Count Files Recursively with Exclusion on Linux

Find all files in this directory, including the files in sub-directories, and exclude all files that start with a period (dot files) and any directories named .thumbs. Then pass the list of results to the wc command to get a total count:

find . ! -name ".*" ! -path "*.thumbs*" -type f | wc -l

Write a Comment

Comment

  1. Almost 10 years old, but exactly THE command I was looking for, thanks a ton 😀
    Needed to exclude two paths actually, so I replaced the first -name with another -path.