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