Let’s assume we have a directory of text files, and we need the grand total line count across all of the files.

My first attempt was this:

find . -type f -print0 | xargs -0 wc -l

I expected this to not give me what I wanted.  I expected it to show me line totals by file - but I was surprised to see a grand total line count at the end.

Then, I saw a variation on the above approach, in a Stack Overflow answer:

How to count all the lines of code in a directory recursively?

(find . -type f -print0 | xargs -0 cat ) | wc -l

Simple and effective - just the grand total.