wc (Unix)
wc (short for English w ord c ount) is a by POSIX and the Single UNIX Specification defined command on the command line , in Unix - and Unix-like is implemented systems.
The program reads the standard input or a list of files and uses it to generate one or more statistics: number of lines, number of words or number of characters. When specifying individual files, the output for each file and a summary are generated.
The program can be called up as follows:
$ wc lorem.txt ipsum.log
40 149 947 lorem.txt
2294 16638 97724 ipsum.log
2334 16787 98671 total
The first column indicates the number of lines. In the example the file has lorem.txt
40 lines. The file, ipsum.log
however, has 2294 lines. The files contain a total of 2334 lines. The second column shows the number of words in the files. The last column shows the number of characters in the files.
Newer versions of wc
can differentiate between bytes and characters . This difference is relevant for Unicode characters, which can have several bytes per character. The behavior can be controlled with the -c
or -m
command line switches.
GNU wc
was part of the GNU textutils package, but is now part of the GNU coreutils package.
use
-
wc -l <filename>
Specifies the number of lines (only if followed by a line break) -
wc -c <filename>
Indicates the number of bytes -
wc -m <filename>
Specifies the number of characters -
wc -L <filename>
Specifies the length of the longest lines (GNU extension) -
wc -w <filename>
Indicates the number of words
See also
Web links
- wc (1) - Original Unix First Edition manual page for wc.
-
The
wc
Command by The Linux Information Project (LINFO)