WC command on Linux (word count)
The wc command on Linux shows the lines, words, and number of characters in a file, in this order.
Suppose you want to count the number of lines, words, or characters in a file. The wc command can be used to count the lines, words, and characters in one or more files. If more than one file is passed as an argument, it will show the statistics for each file and the total.
The most common options are:
- -c: Count the number of characters in one or more files;
- -l: Count the number of lines in one or more files;
- -L: Count the number of characters in the longest line of the file;
- -w: Count the words in one or more files.
In this example, we are going to use the toilet to count the unique items on the grocery list:
Our list has 6 items (one per line), six words, and 41 characters.