wc -- line, word, character, and byte count

wc [-lmcw] [file ...]

Outputs the number of lines, words, and characters in each input file, or standard input (if no file is specified) to the standard output.
A line is defined as a string of characters delimited by a NL .
Characters beyond the final NL will not be included in the line count.

A word is defined as a string of characters delimited by white space characters, the set of characters for which the iswspace(3) function returns true.
If more than one input file is specified, a line of TOTAL counts for all the files is

-l lines
-w words
-c Characters (bytes) cancels out any prior -m
-L Length of longest line
-m If the current locale does not support multibyte characters, equivalent to -c option. cancels prior -c option.
If an option is specified, that information is output.
The order of output always takes the form of line, word, character, and file name.
Default -lwc.
>hexdump -C dafile
00000000 31 2c 32 20 33 09 34 0a 0a 0a |1,2 3.4...|
> wc dafile
3 3 10 dafile
> wc -L dafile
9 dafile
If no files are specified, the standard input is used and no file name is displayed.
The prompt will accept input until receiving EOF Usually [^D]


The LANG, LC_ALL and LC_CTYPE environment variables affect the execution of wc as described in environ(environ

Exits 0 on success, and >0 if an error occurs.


wc: inputFilename:489: Invalid or incomplete multibyte or wide character


Count the number of lines, words and characters in each of the files report1 and report2 as well as the totals for both:
wc -mlw report1 report2

Historically, a word was a "maximal string of characters delimited by ␠ ␉ or characters''.
The implementation, however, did not handle non-printing characters correctly so that " ^D^E " counted as 6 spaces, while "foo^D^Ebar" counted as 8 characters.
4BSD systems after 4.3BSD modified the implementation to be consistent with the documentation.
This implementation defines a "word in terms of the iswspace(3) function, as required by IEEE Std 1003.2 (POSIX.2).

See Also

"Is White Space" : iswspace(widec) - test for whitespace wide character wide-character equivalent of the isspace()tests whether widec is a wide character belonging to the wide character class "space". class "space" is disjoint from the wide character class "graph" and therefore also disjoint from its subclasses "alnum", "alpha", "upper", "lower", "digit", "xdigit", "punct". contains the wide character class "blank". always contains at least the space character and the control characters ’\f’, ’\n’, ’\r’, ’\t’, ’\v’. SEE ALSO isspace(3), iswctype(3) depends on the LC_CTYPE category of the current locale.