Word count in pdf using wc command (on Ubuntu and Mac)

This post introduces how to count the number of words in a pdf file using wc command. It works on both Linux (Ubuntu) and Mac OS.

Note: you do not need to install anything, it is built-in on your Ubuntu/Mac OS.

Step 1: open a terminal 

Step 2: cd to the directory where your pdf file is located 

Step 3: issue the following command

$ ps2ascii example.pdf | wc -w

Step 4: Then you should see the number of words in that example.pdf

 

P.S.   the wc command has several arguments, see below.

wc -l: print the number of lines in a file.

wc -w: print the number of words in a file.

wc -c: print the number of bytes in a file.

wc -m: print the number of characters from a file.

wc -L: print only the length of the longest line in a file.