How can I count the number of words in a directory recursively?

Alistair Colling picture Alistair Colling · Feb 22, 2016 · Viewed 9k times · Source

I'm trying to calculate the number of words written in a project. There are a few levels of folders and lots of text files within them.

Can anyone help me find out a quick way to do this?

bash or vim would be good!

Thanks

Answer

karakfa picture karakfa · Feb 22, 2016

use find the scan the dir tree and wc will do the rest

$ find path -type f | xargs wc -w | tail -1

last line gives the totals.