FG
💻 Software

How do I count the total number of words of all files in a directory (and its subdirectories)?

Fresh5 days ago
Mar 15, 202622876 views
Confidence Score0%
0%

Problem

I am thinking I can do this with wc somehow, if there was a recursive option but I am not sure. I want a grand total of the total number of words in the files under a directory and its subdirectories (not just a per-file word count). Note I am performing this with my mac. Ok, I just tried this comm…

Error Output

find enwiki/ -type f | xargs wc -w > output.txt

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I count the total number of words of all files in a directory (and its subdirectories)?

Low Risk

Using to find all files, then concatenating them with and counting the words in the concatenated stream with : The issue with your command is the will be called multiple times on batches of files if you have many thousands of files to process. In th…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment