wc(1) — Commands
OSF
NAME
wc − Counts the lines, words, and bytes in a file
SYNOPSIS
wc [-lwc] [file ...]
The wc command counts the lines, words, and bytes in a file, or in the standard input if you do not specify any files, and writes the results to standard output. It also keeps a total count for all named files.
FLAGS
-cCounts bytes only.
-lCounts lines only.
-wCounts words only.
DESCRIPTION
A word is defined as a string of characters delimited by white space as defined in the X/Open Base Definitions for XCU4.
The wc command counts lines, words, and bytes by default; use the appropriate flags to limit wc to one or two of the three totals. Specifying wc without flags is the equivalent of specifying wc -lwc.
The order in which line, word, and byte counts appear in the output line matches the order in which the flags are entered on the command line. (If you do not specify any flags, the order is lines, words, bytes.)
When you specify more than one file, wc displays the name of the file along with the counts.
Japanese Language Support
If Japanese Language support is enabled on your system, you can specify an additional flag, -k, along with -c (^He.g. wc -ck) to count characters rather than bytes. Otherwise, -c counts bytes when JLS is enabled.
EXAMPLES
1.To display the the number of lines, words, and bytes in the file text, enter:
wc text
This results in the following output:
27 185 722 text
The numbers 27, 185, and 722 are the number of lines, words, and bytes, respectively, in the file text.
2.To display only one or two of the three counts, or to display the counts you want in a particular order, include the appropriate flags in the order you want. For example, the following command displays only byte and line counts:
wc -cl text
722 27 text
3.To count lines, words, and bytes in more than one file, use wc with more than one input file or with a filename pattern. For example, the following command can be issued in a directory containing the files text, text1, and text2:
wc -l text∗
27text
112text1
5text2
144total
The numbers 27, 112, and 5 are the numbers of lines in the files text, text1, and text2, respectively, and 144 is the total number of lines in the three files.
RELATED INFORMATION
Commands: ls(1).