Count all files in a directory and subdirectories (linux)

July 31, 2020 ≈ 21 seconds

First, we need to find needed files, using the 'find' command. The find utility recursively descends the directory tree for each path listed, evaluating an expression in terms of each file in the tree. Next, we need to count lines, using wc (word, line, character, and byte count) command with -l (lines) parameter.

Let's count all *.conf files in directory and all subdirectories:

find . -name '*.conf' -type f | wc -l

Subscribe to our newsletter

If you provide url of your website, we send you free design concept of one element (by our choice)

Subscribing to our newsletter, you comply with subscription terms and Privacy Policy