xref: /freebsd/bin/cat/cat.1 (revision 74bf4e164ba5851606a27d4feff27717452583e5)
1.\" Copyright (c) 1989, 1990, 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.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 4. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)cat.1	8.3 (Berkeley) 5/2/95
32.\" $FreeBSD$
33.\"
34.Dd March 21, 2004
35.Dt CAT 1
36.Os
37.Sh NAME
38.Nm cat
39.Nd concatenate and print files
40.Sh SYNOPSIS
41.Nm
42.Op Fl benstuv
43.Op Ar
44.Sh DESCRIPTION
45The
46.Nm
47utility reads files sequentially, writing them to the standard output.
48The
49.Ar file
50operands are processed in command-line order.
51If
52.Ar file
53is a single dash
54.Pq Sq \&-
55or absent,
56.Nm
57reads from the standard input.
58If
59.Ar file
60is a
61.Ux
62domain socket,
63.Nm
64connects to it and then reads it until
65.Dv EOF .
66This complements the
67.Ux
68domain binding capability available in
69.Xr inetd 8 .
70.Pp
71The options are as follows:
72.Bl -tag -width indent
73.It Fl b
74Number the non-blank output lines, starting at 1.
75.It Fl e
76Display non-printing characters (see the
77.Fl v
78option), and display a dollar sign
79.Pq Ql \&$
80at the end of each line.
81.It Fl n
82Number the output lines, starting at 1.
83.It Fl s
84Squeeze multiple adjacent empty lines, causing the output to be
85single spaced.
86.It Fl t
87Display non-printing characters (see the
88.Fl v
89option), and display tab characters as
90.Ql ^I .
91.It Fl u
92Disable output buffering.
93.It Fl v
94Display non-printing characters so they are visible.
95Control characters print as
96.Ql ^X
97for control-X; the delete
98character (octal 0177) prints as
99.Ql ^? .
100.Pf Non- Tn ASCII
101characters (with the high bit set) are printed as
102.Ql M-
103(for meta) followed by the character for the low 7 bits.
104.El
105.Sh DIAGNOSTICS
106.Ex -std
107.Sh EXAMPLES
108The command:
109.Bd -literal -offset indent
110.Ic cat file1
111.Ed
112.Pp
113will print the contents of
114.Ar file1
115to the standard output.
116.Pp
117The command:
118.Bd -literal -offset indent
119.Ic cat file1 file2 > file3
120.Ed
121.Pp
122will sequentially print the contents of
123.Ar file1
124and
125.Ar file2
126to the file
127.Ar file3 ,
128truncating
129.Ar file3
130if it already exists.
131See the manual page for your shell (i.e.,
132.Xr sh 1 )
133for more information on redirection.
134.Pp
135The command:
136.Bd -literal -offset indent
137.Ic cat file1 - file2 - file3
138.Ed
139.Pp
140will print the contents of
141.Ar file1 ,
142print data it receives from the standard input until it receives an
143.Dv EOF
144.Pq Sq ^D
145character, print the contents of
146.Ar file2 ,
147read and output contents of the standard input again, then finally output
148the contents of
149.Ar file3 .
150Note that if the standard input referred to a file, the second dash
151on the command-line would have no effect, since the entire contents of the file
152would have already been read and printed by
153.Nm
154when it encountered the first
155.Ql \&-
156operand.
157.Sh SEE ALSO
158.Xr head 1 ,
159.Xr more 1 ,
160.Xr pr 1 ,
161.Xr sh 1 ,
162.Xr tail 1 ,
163.Xr vis 1 ,
164.Xr zcat 1 ,
165.Xr setbuf 3
166.Rs
167.%A Rob Pike
168.%T "UNIX Style, or cat -v Considered Harmful"
169.%J "USENIX Summer Conference Proceedings"
170.%D 1983
171.Re
172.Sh STANDARDS
173The
174.Nm
175utility is compliant with the
176.St -p1003.2-92
177specification.
178.Pp
179The flags
180.Op Fl benstv
181are extensions to the specification.
182.Sh HISTORY
183A
184.Nm
185utility appeared in
186.At v1 .
187.An Dennis Ritchie
188designed and wrote the first man page.
189It appears to have been
190.Xr cat 1 .
191.Sh BUGS
192Because of the shell language mechanism used to perform output
193redirection, the command
194.Dq Li cat file1 file2 > file1
195will cause the original data in file1 to be destroyed!
196.Pp
197The
198.Nm
199utility does not recognize multibyte characters when the
200.Fl t
201or
202.Fl v
203option is in effect.
204