xref: /original-bsd/usr.bin/wc/wc.1 (revision a1c2194a)
1.\" Copyright (c) 1991 Regents of the University of California.
2.\" 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	6.4 (Berkeley) 06/27/91
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 reads one or more input text files, and, by
25default, writes the number of lines, words, and bytes
26contained in each input file to the standard output.
27If more than one input file is specified,
28a line of cumulative count(s) for all named files is output on a
29separate line
30following the last file count.
31.Nm Wc
32considers a word to be a maximal string of
33characters delimited by white space.
34.Pp
35The following options are available:
36.Bl -tag -width Ds
37.It Fl c
38The number of bytes in each input file
39is written to the standard output.
40.It Fl l
41The number of lines in each input file
42is written to the standard output.
43.It Fl w
44The number of words in each input file
45is written to the standard output.
46.El
47.Pp
48When an option is specified,
49.Nm wc
50only
51reports the
52information requested by that option. The
53default action is equivalent to all the
54flags
55.Fl clw
56having been specified.
57.Pp
58The following operands are available:
59.Bl -tag -width Ds
60.It Ar file
61A pathname of an input file.
62.El
63.Pp
64If no file names
65are specified, the standard input is used and
66a file name is not output. The resulting output is one
67line of the requested count(s) with the cumulative sum
68of all files read in via standard input.
69.Pp
70By default, the standard output contains a line for each
71input file of the form:
72.Bd -literal -offset indent
73lines	 words	bytes	file_name
74.Ed
75.Pp
76The counts for lines, words and bytes are integers separated
77by spaces.
78The ordering of the display of the number of lines, words,
79and/or bytes is the order in which the options were specified.
80.Pp
81The
82.Nm wc
83utility exits 0 on success, and >0 if an error occurs.
84.Sh STANDARDS
85The
86.Nm wc
87function conforms to
88.St -p1003.2 .
89