Counting lines, words, characters in text files with Linux with wc
Follow @ggarronThere are a lot of useful tools in Linux wc is one of them this tool let us know the number of:
Lines words Characters
that we could find in a text file, its use is very simple, so if you are asking
How to count lines, how to count words or how to count characters, you can use this tool.
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
i.e.
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.