xref: /original-bsd/usr.bin/wc/wc.1 (revision ba762ddc)
1.\" Copyright (c) 1991 Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)wc.1	6.3 (Berkeley) 04/23/91
7.\"
8.Dd
9.Dt WC 1
10.Os
11.Sh NAME
12.Nm wc
13.Nd word, line, and byte count
14.Sh SYNOPSIS
15.Nm wc
16.Op Fl clw
17.Op Ar file ...
18.Sh DESCRIPTION
19The
20.Nm wc
21utility reads one or more input text files, and, by
22default, writes the number of lines, words, and bytes
23contained in each input file to the standard output.
24If more than one input file is specified,
25a line of cumulative count(s) for all named files is output on a
26separate line
27following the last file count.
28.Nm Wc
29considers a word to be a maximal string of
30characters delimited by white space.
31.Pp
32The following options are available:
33.Bl -tag -width Ds
34.It Fl c
35The number of bytes in each input file
36is written to the standard output.
37.It Fl l
38The number of lines in each input file
39is written to the standard output.
40.It Fl w
41The number of words in each input file
42is written to the standard output.
43.El
44.Pp
45When an option is specified,
46.Nm wc
47only
48reports the
49information requested by that option. The
50default action is equivalent to all the
51flags
52.Fl clw
53having been specified.
54.Pp
55The following operands are available:
56.Bl -tag -width Ds
57.It Ar file
58A pathname of an input file.
59.El
60.Pp
61If no file names
62are specified, the standard input is used and
63a file name is not output. The resulting output is one
64line of the requested count(s) with the cumulative sum
65of all files read in via standard input.
66.Pp
67By default, the standard output contains a line for each
68input file of the form:
69.Bd -literal -offset indent
70lines	 words	bytes	file_name
71.Ed
72.Pp
73The counts for lines, words and bytes are integers separated
74by spaces.
75The ordering of the display of the number of lines, words,
76and/or bytes is the order in which the options were specified.
77.Pp
78The
79.Nm wc
80utility exits 0 on success, and >0 if an error occurs.
81.Sh STANDARDS
82The
83.Nm wc
84function conforms to
85.St -p1003.2 .
86