OpenBSD manual page server

Manual Page Search Parameters

WC(1) General Commands Manual WC(1)

wcword, line, and byte or character count

wc [-c | -m] [-hlw] [file ...]

The wc utility reads one or more input text files and, by default, writes the number of lines, words, and bytes contained in each input file to the standard output. If more than one input file is specified, a line of cumulative count(s) for all named files is output on a separate line following the last file count. wc considers a word to be a maximal string of characters delimited by whitespace. Whitespace characters are the set of characters for which the isspace(3) function returns true.

The options are as follows:

The number of bytes in each input file is written to the standard output.
Use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce the number of digits to four or fewer using powers of 2 for sizes (K=1024, M=1048576, etc.).
The number of lines in each input file is written to the standard output.
Count characters instead of bytes, and use iswspace(3) instead of isspace(3).
The number of words in each input file is written to the standard output.

When an option is specified, wc only reports the information requested by that option. The default action is equivalent to the flags -clw having been specified.

If no file names are specified, the standard input is used and a file name is not output. The resulting output is one line of the requested count(s) with the cumulative sum of all files read in via standard input.

By default, the standard output contains a line for each input file of the form:

lines	 words	bytes	file_name

The counts for lines, words, and bytes (or characters) are integers separated by spaces.

The character encoding locale(1). It decides which byte sequences form characters. If unset or set to "C", "POSIX", or an unsupported value, -m has the same effect as -c.

The wc utility exits 0 on success, and >0 if an error occurs.

isspace(3)

The wc utility is compliant with the specification.

The flag [-h] is an extension to that specification.

A wc utility appeared in Version 1 AT&T UNIX.

September 11, 2024 OpenBSD-current