command is used to count the number of lines, words, and characters in a file.
Observe what happens when you run the
command on the following file.
$ cat letter
Final exams are coming up next week.
Please send food, clothes, and
$ wc letter
9 17 101 letter
command tells you that this file has 9 lines, 17 words, and 101 characters.
You can display only the number of lines by using the
option, the number of words by using the
option, or the number of characters by using the
Here is the
command using the
$ wc l letter
Saving the line count in a variable
To save the number of lines to a variable, embed the
wc command in an assignment statement. -
The next lesson demonstrates sorting the content of a text file using the
WC Command - Exercise