This post was originally published on go2linux.org, a Linux blog I ran from 2007 to 2011. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.
There are a lot of useful tools in Linux and wc is one of them, this tool let us know the number of:
Lines, words or characters that we could find in a text file, its use is very simple:
Usage
wc [OPTION]… [FILE]…
Where the options are
-c, --bytes
print the byte counts
-m, --chars
print the character counts
-l, --lines
print the newline counts
-L, --max-line-length
print the length of the longest line
-w, --words
print the word counts
For example
Suppose you have a file called mytextfile.txt and would like to know how many lines and words it have just enter:
wc -l -w mytextfile.txt
The output will be like this.
7334 22002 /home/user/mytextfile.txt
So it has 7334 lines and 22002 words.