Use wc on all subdirectories to count the sum of lines Use wc on all subdirectories to count the sum of lines bash bash

Use wc on all subdirectories to count the sum of lines


You probably want this:

find . -type f -print0 | wc -l --files0-from=-

If you only want the total number of lines, you could use

find . -type f -exec cat {} + | wc -l


Perhaps you are looking for exec option of find.

find . -type f -exec wc -l {} \; | awk '{total += $1} END {print total}'


To count all lines for specific file extension u can use ,

find . -name '*.fileextension' | xargs wc -l

if you want it on two or more different types of files u can put -o option

find . -name '*.fileextension1' -o -name '*.fileextension2' | xargs wc -l