]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - bin/cat/cat.1
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.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 .\" 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
46 The
47 .Nm
48 utility reads files sequentially, writing them to the standard output.
49 The
50 .Ar file
51 operands are processed in command-line order.
52 If
53 .Ar file
54 is a single dash
55 .Pq Sq Fl
56 or absent,
57 .Nm
58 reads from the standard input.
59 If
60 .Ar file
61 is a
62 .Ux
63 domain socket,
64 .Nm
65 connects to it and then reads it until
66 .Dv EOF .
67 This complements the
68 .Ux
69 domain binding capability available in
70 .Xr inetd 8 .
71 .Pp
72 The options are as follows:
73 .Bl -tag -width indent
74 .It Fl b
75 Number the non-blank output lines, starting at 1.
76 .It Fl e
77 Display non-printing characters (see the
78 .Fl v
79 option), and display a dollar sign
80 .Pq Ql \&$
81 at the end of each line.
82 .It Fl l
83 Set an exclusive advisory lock on the standard output file descriptor.
84 This lock is set using
85 .Xr fcntl 2
86 with the
87 .Dv F_SETLKW
88 command.
89 If the output file is already locked,
90 .Nm
91 will block until the lock is acquired.
92 .It Fl n
93 Number the output lines, starting at 1.
94 .It Fl s
95 Squeeze multiple adjacent empty lines, causing the output to be
96 single spaced.
97 .It Fl t
98 Display non-printing characters (see the
99 .Fl v
100 option), and display tab characters as
101 .Ql ^I .
102 .It Fl u
103 Disable output buffering.
104 .It Fl v
105 Display non-printing characters so they are visible.
106 Control characters print as
107 .Ql ^X
108 for control-X; the delete
109 character (octal 0177) prints as
110 .Ql ^? .
111 .Pf Non- Tn ASCII
112 characters (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
119 The command:
120 .Pp
121 .Dl "cat file1"
122 .Pp
123 will print the contents of
124 .Pa file1
125 to the standard output.
126 .Pp
127 The command:
128 .Pp
129 .Dl "cat file1 file2 > file3"
130 .Pp
131 will sequentially print the contents of
132 .Pa file1
133 and
134 .Pa file2
135 to the file
136 .Pa file3 ,
137 truncating
138 .Pa file3
139 if it already exists.
140 See the manual page for your shell (e.g.,
141 .Xr sh 1 )
142 for more information on redirection.
143 .Pp
144 The command:
145 .Pp
146 .Dl "cat file1 - file2 - file3"
147 .Pp
148 will print the contents of
149 .Pa file1 ,
150 print data it receives from the standard input until it receives an
151 .Dv EOF
152 .Pq Sq ^D
153 character, print the contents of
154 .Pa file2 ,
155 read and output contents of the standard input again, then finally output
156 the contents of
157 .Pa file3 .
158 Note that if the standard input referred to a file, the second dash
159 on the command-line would have no effect, since the entire contents of the file
160 would have already been read and printed by
161 .Nm
162 when it encountered the first
163 .Sq Fl
164 operand.
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
182 The
183 .Nm
184 utility is compliant with the
185 .St -p1003.2-92
186 specification.
187 .Pp
188 The flags
189 .Op Fl belnstv
190 are extensions to the specification.
191 .Sh HISTORY
192 A
193 .Nm
194 utility appeared in
195 .At v1 .
196 .An Dennis Ritchie
197 designed and wrote the first man page.
198 It appears to have been
199 .Xr cat 1 .
200 .Sh BUGS
201 Because of the shell language mechanism used to perform output
202 redirection, the command
203 .Dq Li cat file1 file2 > file1
204 will cause the original data in
205 .Pa file1
206 to be destroyed!
207 .Pp
208 The
209 .Nm
210 utility does not recognize multibyte characters when the
211 .Fl t
212 or
213 .Fl v
214 option is in effect.