# Mac – What command counts the number of an specific type of file (eg: csv) in a directory on OS X

command linefilesystemsmac

What is the command line to count the number of an specific type of file (eg: csv) of a directory on OS X (only files, excluding directories and subdirectories)?

The below command works for any kind, but it's considering other types.

find [directory] -print | wc -l


• The following command will count the number of .csv files in the current directory and all subdirectories.
find . -type f -iname '*.csv' | wc -l

Find in the current directory . (and all subdirectories), a file -type f, matching a case-insensitive pattern -iname *.csv.