wc - paragraph, line, word, character, and byte counter


wc [-a | [-p] [-l] [-w] [-m] [-c] ] [file1 [file2...]]


wc 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. An optional count of paragraphs or characters is also possible in this implementation. If more than one text file is specified, a line of total count(s) for all named files is output on a separate line following the last file count. If no input files are specified, standard input is read.

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

     lines     words     bytes file_name

With all options specified the output line for each input file is of the form:

     paras     lines     words     chars     bytes file_name

wc uses Perl's use locale pragma.



No options to wc is equivalent to specifying -l -w and -c.


Is equivalent to specifying -p -l -w -m and -c.


Tells wc to count paragraphs in the input file(s). The algorithm employed counts lumped groups of lines that do not contain only zero or more space characters (/^\s*$/). This regular expression is sensitive to locale settings.


Tells wc to count lines in the input file(s).


Tells wc to count words in the input file(s) as determined by perl's /\w+/ regular expression which is locale sensitive.


Tells wc to count characters in the input file(s). This is implemented with a multi-byte character counting regular expression m/$encoding/gox. The $encoding defaults to one sensitive to well formed UTF-8 encodings (one to six byte characters) though this may be altered to other encodings by alteration of the program code. Note that some 8 bit single byte characters will be missed by the UTF-8 character counter since such characters fall outside the UTF-8 encoding.


Tells wc to count bytes in the input file(s). This is implemented with perl's "length" in perlfunc built in function.


The working of wc may be influenced by your locale since it uses the locale pragma and this could have an effect on -w (word) and -p (paragraph) counts. wc may also be influenced by PERLLIB or PERL5LIB since it uses File::Basename, locale, and strict internally.




wc has no known bugs.


The -a and -p options are peculiarities of this Perl implementation.


Peter Prymmer


This program is copyright (c) by Peter Prymmer 1999.

This program is free and open software. You may use, copy, modify, distribute and sell this program (and any modified variants) in any way you wish, provided you do not restrict others to do the same.