wc (short for word count) is a command in Unix-like operating systems.
The program reads either standard input or a list of files and generates one or more of the following statistics: number of bytes, number of words, and number of lines (specifically, the number of newline characters). If a list of files is provided, both individual file and total statistics follow.
Sample execution of wc:
baldur@baldur-laptop:~$ wc ideas.txt excerpt.txt
40 149 947 ideas.txt
2294 16638 97724 excerpt.txt
2334 16787 98671 total
The first column is the count of newlines, meaning that the text file ideas.txt has 40 newlines while excerpt.txt has 2294 newlines- resulting in a total of 2334 newlines. The second column indicates the number of words in each text file showing that there are 149 words in ideas.txt and 16638 words in excerpt.txt- giving a total of 16787 words. The last column indicates the number of characters in each text file, meaning that the file ideas.txt has 947 characters while excerpt.txt has 97724 characters- 98671 characters all in all.
Newer versions of wc can differentiate between byte and character count. This difference arises with Unicode which includes multi-byte characters. The desired behaviour is selected with the -c or -m switch.
GNU wc used to be part of the GNU textutils package; it is now part of GNU coreutils.
[edit] Usage
- wc -l <filename> print the line count
- wc -c <filename> print the byte count
- wc -m <filename> print the character count
- wc -L <filename> print the length of longest line
- wc -w <filename> print the word count
[edit] See also
[edit] External links
- [1] The program's manpage
- The wc Command by The Linux Information Project (LINFO)
|
||||||||||||||||||||||||||