Merge branch 'vendor/TNFTP'
[dragonfly.git] / bin / cat / cat.1
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 .\" 3. 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: src/bin/cat/cat.1,v 1.27 2006/12/23 09:25:23 ru Exp $
34 .\" $DragonFly: src/bin/cat/cat.1,v 1.6 2007/02/04 21:08:28 pavalos Exp $
35 .\"
36 .Dd March 21, 2004
37 .Dt CAT 1
38 .Os
39 .Sh NAME
40 .Nm cat
41 .Nd concatenate and print files
42 .Sh SYNOPSIS
43 .Nm
44 .Op Fl benstuv
45 .Op Ar
46 .Sh DESCRIPTION
47 The
48 .Nm
49 utility reads files sequentially, writing them to the standard output.
50 The
51 .Ar file
52 operands are processed in command-line order.
53 If
54 .Ar file
55 is a single dash
56 .Pq Sq Fl
57 or absent,
58 .Nm
59 reads from the standard input.
60 If
61 .Ar file
62 is a
63 .Ux
64 domain socket,
65 .Nm
66 connects to it and then reads it until
67 .Dv EOF .
68 This complements the
69 .Ux
70 domain binding capability available in
71 .Xr inetd 8 .
72 .Pp
73 The options are as follows:
74 .Bl -tag -width indent
75 .It Fl b
76 Number the non-empty output lines, starting at 1.
77 .It Fl e
78 Display non-printing characters (see the
79 .Fl v
80 option), and display a dollar sign
81 .Pq Ql \&$
82 at the end of each line.
83 .It Fl n
84 Number the output lines, starting at 1.
85 .It Fl s
86 Squeeze multiple adjacent empty lines, causing the output to be
87 single spaced.
88 .It Fl t
89 Display non-printing characters (see the
90 .Fl v
91 option), and display tab characters as
92 .Ql ^I .
93 .It Fl u
94 Disable output buffering.
95 .It Fl v
96 Display non-printing characters so they are visible.
97 Control characters print as
98 .Ql ^X
99 for control-X; the delete
100 character (octal 0177) prints as
101 .Ql ^? .
102 .Pf Non- Tn ASCII
103 characters (with the high bit set) are printed as
104 .Ql M-
105 (for meta) followed by the character for the low 7 bits.
106 .El
107 .Sh EXIT STATUS
108 .Ex -std
109 .Sh EXAMPLES
110 The command:
111 .Pp
112 .Dl "cat file1"
113 .Pp
114 will print the contents of
115 .Pa file1
116 to the standard output.
117 .Pp
118 The command:
119 .Pp
120 .Dl "cat file1 file2 > file3"
121 .Pp
122 will sequentially print the contents of
123 .Pa file1
124 and
125 .Pa file2
126 to the file
127 .Pa file3 ,
128 truncating
129 .Pa file3
130 if it already exists.
131 See the manual page for your shell (i.e.,
132 .Xr sh 1 )
133 for more information on redirection.
134 .Pp
135 The command:
136 .Pp
137 .Dl "cat file1 - file2 - file3"
138 .Pp
139 will print the contents of
140 .Pa file1 ,
141 print data it receives from the standard input until it receives an
142 .Dv EOF
143 .Pq Sq ^D
144 character, print the contents of
145 .Pa file2 ,
146 read and output contents of the standard input again, then finally output
147 the contents of
148 .Pa file3 .
149 Note that if the standard input referred to a file, the second dash
150 on the command-line would have no effect, since the entire contents of the file
151 would have already been read and printed by
152 .Nm
153 when it encountered the first
154 .Sq Fl
155 operand.
156 .Sh SEE ALSO
157 .Xr head 1 ,
158 .Xr more 1 ,
159 .Xr pr 1 ,
160 .Xr sh 1 ,
161 .Xr tail 1 ,
162 .Xr vis 1 ,
163 .Xr zcat 1 ,
164 .Xr setbuf 3
165 .Rs
166 .%A Rob Pike
167 .%T "UNIX Style, or cat -v Considered Harmful"
168 .%J "USENIX Summer Conference Proceedings"
169 .%D 1983
170 .Re
171 .Sh STANDARDS
172 The
173 .Nm
174 utility conforms to
175 .St -p1003.2-92
176 and
177 .St -p1003.1-2004 .
178 .Pp
179 The flags
180 .Op Fl benstv
181 are extensions to the specification.
182 .Sh HISTORY
183 A
184 .Nm
185 utility appeared in
186 .At v1 .
187 .An Dennis Ritchie
188 designed and wrote the first man page.
189 It appears to have been
190 .Xr cat 1 .
191 .Sh BUGS
192 Because of the shell language mechanism used to perform output
193 redirection, the command
194 .Dq Li cat file1 file2 > file1
195 will cause the original data in
196 .Pa file1
197 to be destroyed!
198 .Pp
199 The
200 .Nm
201 utility does not recognize multibyte characters when the
202 .Fl t
203 or
204 .Fl v
205 option is in effect.