Wc

Syntax:

wc [-lwc] filename

The wc (word count) command counts lines, characters, and words. If you use the wc command without any options, the output displays all statistics of the file. The file test.txt contains the following text:

the quick brown fox jumps over the lazy dog wc test.txt

1 9 44 test.txt

The results tell us there is one line with nine words containing 44 characters in the file test.txt. To display only the number of lines, use the -l option. The -w option displays only the number of words. Finally, the -c option displays only the total number of characters.

Was this article helpful?

0 0

Post a comment