Count number of lines, words and characters on Linux

wc file.txt

In case you are still reading, that is it.

For a more detailed explanation, you open a terminal type "wc" and then specify your text file you want to count words or whatever, the output will give you three numbers, first number is lines, second is words and third is bytes/characters. For character count you have to consider that the program seems to count empty spaces, line breaks also as characters, which indeed they are for the computer. If you want to specify what exactly you want to count, then you can do that using flags, like "wc -w file.txt" which will only count the words. To find out all the flags you can use type "man wc" and it will tell you in the manual.

You can also count multiple files at the same time with:

wc file.txt file2.txt file3.txt

The output will be in a table where you can easily compare the files word count and it will give you also the total results of all files added together.

Tutorial Reference: