wc - word, line and byte or character count
wc [-c|-m][-lw][file...]
The wc utility reads one or more input files and, by default, writes the number of newline characters, words and bytes contained in each input file to the standard output.The utility also writes a total count for all named files, if more than one input file is specified.
The wc utility considers a word to be a non-zero-length string of characters delimited by white space.
The wc utility supports the XBD specification, Utility Syntax Guidelines .The following options are supported:
- -c
- Write to the standard output the number of bytes in each input file.
- -l
- Write to the standard output the number of newline characters in each input file.
- -m
- Write to the standard output the number of characters in each input file.
- -w
- Write to the standard output the number of words in each input file.
When any option is specified, wc will report only the information requested by the specified options.
The following operand is supported:
- file
- A pathname of an input file. If no file operands are specified, the standard input will be used.
The standard input will be used only if no file operands are specified. See the INPUT FILES section.
The input files may be of any type.
The following environment variables affect the execution of wc:
- LANG
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- LC_ALL
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- LC_CTYPE
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments and input files) and which characters are defined as white space characters.
- LC_MESSAGES
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output.
- NLSPATH
- Determine the location of message catalogues for the processing of LC_MESSAGES .
Default.
By default, the standard output contains an entry for each input file of the form:
"%d %d %d %s\n", <newlines>, <words>, <bytes>, <file>
If the -m option is specified, the number of characters replace the <bytes> field in this format.
If any options are specified and the -l option is not specified, the number of newline characters will not be written.
If any options are specified and the -w option is not specified, the number of words will not be written.
If any options are specified and neither -c nor -m is specified, the number of bytes or characters will not be written.
If no input file operands are specified, no name will be written and no blank characters preceding the pathname will be written.
If more than one input file operand is specified, an additional line will be written, of the same format as the other lines, except that the word total (in the POSIX locale) will be written instead of a pathname and the total of each column will be written as appropriate. Such an additional line, if any, will be written at the end of the output.
Used only for diagnostic messages.
None.
None.
The following exit values are returned:
- 0
- Successful completion.
- >0
- An error occurred.
Default.
The -m option is not a switch, but an option at the same level as -c. Thus, to produce the full default output with character counts instead of bytes, the command required is:wc -mlw
None.
None.
cksum.