The most easiest way to count the number of lines, words,a nad characters in text file is to use the command “wc” in terminal. The command “wc” basically means “word count” and with different optional parameters one can use it to count the number of lines, words, and characters in a text file.
To count the number of lines, use “wc” with “l” as
wc -l yourTextFile
To count the number of words, use “wc” with “w” option as
wc -w yourTextFile
And to count the total number of characters, use “wc” with “c” as
wc -c yourTextFile
More Counting: Count a Certain Type of Files in a Directory
One can also cleverly use the “wc” command on terminal and find the number of files (or files of certain type) in a directory. For example, to find the number of pdf files in a directory
ls -l *.pdf | wc -l
And remember that the first line of “ls -l” statement is a description. Therefore, the total number of pdf files is one less than the result of “ls -l *.pdf | wc -l“.