wccount of newlines, words, bytes, and characters |
Command |
wc
[-c
|-m
]
[-lw
] [file ...]
wc
counts the number of newlines, words, characters and
bytes in text files. If you specify multiple files, wc
produces counts for each file, plus totals for all files. If you did not specify
any options, wc
produces the following output:
When you specify options,newline_count word_count byte_count filename
wc
displays only the selected
counts in the same order as the default output. If you specify
-m
, the character count replaces the byte count. For example,
-cw
displays the word count followed by the byte count and
the file name and -ml
displays the newline count followed by
the character count and file name.
A word is considered to be a character or characters delimited by white space.
The -c
option of wc
counts
bytes, not characters. This is a change from previous versions of
wc
, dictated by the POSIX.2 standard which provides
the -m
option to count characters. If you have a file
containing multibyte characters, the byte count is higher than the
character count.
-c
displays a byte count. You cannot specify this option with
-m
.
-l
displays a newline count.
-m
displays a character count. You cannot specify this option with
-c
.
-w
displays a word count.
0
Successful completion.
1
Failure because of an inability to open the input file.
2
Failure because of an invalid command line option.