Counting words of a text file can be accomplished with a command wc
, which stands for word count. Please note that these instructions only apply to text files, not binary files.
If your file is named as myfile.txt
, type following command in the terminal:
$ wc -w myfile.txt
w
stands for words.
The output is the number of words in the file.
If you want to count number of word occurences you need more sophisticated method. Read this: Count Word Occurences in File in Linux