xref: /original-bsd/usr.bin/wc/wc.1 (revision e58c8952)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\"     @(#)wc.1	8.2 (Berkeley) 04/19/94
10.\"
11.Dd
12.Dt WC 1
13.Os
14.Sh NAME
15.Nm wc
16.Nd word, line, and byte count
17.Sh SYNOPSIS
18.Nm wc
19.Op Fl clw
20.Op Ar file ...
21.Sh DESCRIPTION
22The
23.Nm wc
24utility displays the number of lines, words, and bytes contained in each
25input
26.Ar file
27(or standard input, by default) to the standard output.
28A line is defined as a string of characters delimited by a <newline>
29character,
30and a word is defined as a string of characters delimited by white space
31characters.
32White space characters are the set of characters for which the
33.Xr isspace 3
34function returns true.
35If more than one input file is specified, a line of cumulative counts
36for all the files is displayed on a separate line after the output for
37the last file.
38.Pp
39The following options are available:
40.Bl -tag -width Ds
41.It Fl c
42The number of bytes in each input file
43is written to the standard output.
44.It Fl l
45The number of lines in each input file
46is written to the standard output.
47.It Fl w
48The number of words in each input file
49is written to the standard output.
50.El
51.Pp
52When an option is specified,
53.Nm wc
54only reports the information requested by that option.
55The default action is equivalent to specifying all of the flags.
56.Pp
57If no files are specified, the standard input is used and no
58file name is displayed.
59.Pp
60The
61.Nm wc
62utility exits 0 on success, and >0 if an error occurs.
63.Sh SEE ALSO
64.Xr isspace 3
65.Sh COMPATIBILITY
66Historically, the
67.Nm wc
68utility was documented to define a word as a ``maximal string of
69characters delimited by <space>, <tab> or <newline> characters''.
70The implementation, however, didn't handle non-printing characters
71correctly so that ``  ^D^E  '' counted as 6 spaces, while ``foo^D^Ebar''
72counted as 8 characters.
734BSD systems after 4.3BSD modified the implementation to be consistent
74with the documentation.
75This implementation defines a ``word'' in terms of the
76.Xr isspace 3
77function, as required by
78.St -p1003.2 .
79.Sh STANDARDS
80The
81.Nm wc
82function conforms to
83.St -p1003.2 .
84