1.\" $NetBSD: wc.1,v 1.12 2002/03/05 15:09:46 wiz Exp $ 2.\" 3.\" Copyright (c) 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" This code is derived from software contributed to Berkeley by 7.\" the Institute of Electrical and Electronics Engineers, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the University of 20.\" California, Berkeley and its contributors. 21.\" 4. Neither the name of the University nor the names of its contributors 22.\" may be used to endorse or promote products derived from this software 23.\" without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35.\" SUCH DAMAGE. 36.\" 37.\" from: @(#)wc.1 8.2 (Berkeley) 4/19/94 38.\" 39.Dd April 19, 1994 40.Dt WC 1 41.Os 42.Sh NAME 43.Nm wc 44.Nd word, line, and byte count 45.Sh SYNOPSIS 46.Nm 47.Op Fl c | Fl m 48.Op Fl lw 49.Op Ar file ... 50.Sh DESCRIPTION 51The 52.Nm 53utility displays the number of lines, words, bytes and characters contained in each 54input 55.Ar file 56(or standard input, by default) to the standard output. 57A line is defined as a string of characters delimited by a \*[Lt]newline\*[Gt] 58character, 59and a word is defined as a string of characters delimited by white space 60characters. 61White space characters are the set of characters for which the 62.Xr iswspace 3 63function returns true. 64If more than one input file is specified, a line of cumulative counts 65for all the files is displayed on a separate line after the output for 66the last file. 67.Pp 68The following options are available: 69.Bl -tag -width Ds 70.It Fl c 71The number of bytes in each input file 72is written to the standard output. 73.It Fl l 74The number of lines in each input file 75is written to the standard output. 76.It Fl m 77The number of characters in each input file 78is written to the standard output. 79.It Fl w 80The number of words in each input file 81is written to the standard output. 82.El 83.Pp 84When an option is specified, 85.Nm 86only 87reports the 88information requested by that option. The 89default action is equivalent to all the 90flags 91.Fl clw 92having been specified. 93.Pp 94The following operands are available: 95.Bl -tag -width Ds 96.It Ar file 97A pathname of an input file. 98.El 99.Pp 100If no file names 101are specified, the standard input is used and 102no file name is displayed. 103.Pp 104By default, the standard output contains a line for each 105input file of the form: 106.Bd -literal -offset indent 107lines words bytes file_name 108.Ed 109.Pp 110The 111.Nm 112utility exits 0 on success, and \*[Gt]0 if an error occurs. 113.Sh SEE ALSO 114.Xr iswspace 3 115.Sh COMPATIBILITY 116Historically, the 117.Nm 118utility was documented to define a word as a ``maximal string of 119characters delimited by \*[Lt]space\*[Gt], \*[Lt]tab\*[Gt] or \*[Lt]newline\*[Gt] characters''. 120The implementation, however, didn't handle non-printing characters 121correctly so that `` ^D^E '' counted as 6 spaces, while ``foo^D^Ebar'' 122counted as 8 characters. 123.Bx 4 124systems after 125.Bx 4.3 126modified the implementation to be consistent 127with the documentation. 128This implementation defines a ``word'' in terms of the 129.Xr iswspace 3 130function, as required by 131.St -p1003.2 . 132.Sh STANDARDS 133The 134.Nm 135utility conforms to 136.St -p1003.2-92 . 137