1cat(1) User Commands cat(1)
2
3
4
6 cat - concatenate and display files
7
9 /usr/bin/cat
10 /usr/bin/cat [-nbsuvet] [file...]
11
12
13 ksh93
14 cat [-bdenstuvABDEST] [file...]
15
16
18 /usr/bin/cat
19 The cat utility reads each file in sequence and writes it on the stan‐
20 dard output. Thus:
21
22 example% cat file
23
24
25
26
27 prints file on your terminal, and:
28
29 example% cat file1 file2 >file3
30
31
32
33
34 concatenates file1 and file2, and writes the results in file3. If no
35 input file is given, cat reads from the standard input file.
36
37 ksh93
38 The cat built-in in ksh93 is associated with the /bin and /usr/bin
39 paths. It is invoked when cat is executed without a pathname prefix and
40 the pathname search finds a /bin/cat or /usr/bin/cat executable. cat
41 copies each file in sequence to the standard output. If no file is
42 specified, or if the file is -, cat copies from standard input starting
43 at the current location.
44
46 /usr/bin/cat
47 The following options are supported by /usr/bin/cat:
48
49 -b Number the lines, as -n, but omit the line numbers from blank
50 lines.
51
52
53 -n Precede each line output with its line number.
54
55
56 -s cat is silent about non-existent files.
57
58
59 -u The output is not buffered.
60
61 Buffered output is the default.
62
63
64 -v Non-printing characters, with the exception of tabs, NEWLINEs and
65 form feeds, are printed visibly. ASCII control characters (octal
66 000 − 037) are printed as ^n, where n is the corresponding ASCII
67 character in the range octal 100 − 137 (@, A, B, C, . . ., X, Y,
68 Z, [, \, ], ^, and _); the DEL character (octal 0177) is printed
69 ^?. Other non-printable characters are printed as M-x, where x is
70 the ASCII character specified by the low-order seven bits.
71
72
73
74 When used with the -v option, the following options can be used:
75
76 -e A $ character is printed at the end of each line, prior to the
77 NEWLINE.
78
79
80 -t Tabs are printed as ^Is and form feeds to be printed as ^Ls.
81
82
83
84 The -e and -t options are ignored if the -v option is not specified.
85
86 ksh93
87 ksh93 cat supports the following options:
88
89 -b --number-nonblank Number lines as with -n but omit line numbers
90 from blank lines.
91
92
93 -d --dos-input Open input files in text mode. Removes RETURNs
94 in front of NEWLINEs on some systems.
95
96
97 -e Equivalent to -vE.
98
99
100 -n --number Insert a line number at the beginning of each
101 line.
102
103
104 -s Equivalent to -S for att universe and -B oth‐
105 erwise.
106
107
108 -t Equivalent to -vT.
109
110
111 -u --unbuffer Do not delay the output by buffering.
112
113
114 -v --show-nonprinting Cause non-printing characters (with the excep‐
115 tion of TABs, NEWLINEs, and form feeds) to be
116 output as printable character sequences. ASCII
117 control characters are printed as ^n, where n
118 is the corresponding ASCII character in the
119 range octal 100-137. The DEL character (octal
120 0177) is copied as ^?. Other non-printable
121 characters are copied as M-x where x is the
122 ASCII character specified by the low-order
123 seven bits. Multi-byte characters in the cur‐
124 rent locale are treated as printable charac‐
125 ters.
126
127
128 -A --show-all Equivalent to -vET.
129
130
131 -B --squeeze-blank Replace multiple adjacent NEWLINE characters
132 with one NEWLINE.
133
134
135 -D --dos-output Open output files in text mode. Insert RETURNs
136 in front of NEWLINEs on some systems.
137
138
139 -E --show-ends Insert a $ before each NEWLINE.
140
141
142 -S --silent cat is silent about non-existent files.
143
144
145 -T --show-blank Copies TABs as ^I and form feeds as ^L.
146
147
149 The following operand is supported:
150
151 file A path name of an input file. If no file is specified, the
152 standard input is used. If file is −, cat reads from the stan‐
153 dard input at that point in the sequence. cat does not close
154 and reopen standard input when it is referenced in this way,
155 but accepts multiple occurrences of − as file.
156
157
159 See largefile(5) for the description of the behavior of cat when
160 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
161
163 Example 1 Concatenating a File
164
165
166 The following command writes the contents of the file myfile to stan‐
167 dard output:
168
169
170 example% cat myfile
171
172
173
174 Example 2 Concatenating Two files into One
175
176
177 The following command concatenates the files doc1 and doc2 and writes
178 the result to doc.all.
179
180
181 example% cat doc1 doc2 > doc.all
182
183
184
185 Example 3 Concatenating Two Arbitrary Pieces of Input with a Single
186 Invocation
187
188
189 When standard input is a terminal, the following command gets two arbi‐
190 trary pieces of input from the terminal with a single invocation of
191 cat:
192
193
194 example% cat start - middle - end > file
195
196
197
198
199 when standard input is a terminal, gets two arbitrary pieces of input
200 from the terminal with a single invocation of cat.
201
202
203
204 If standard input is a regular file,
205
206
207 example% cat start - middle - end > file
208
209
210
211
212 would be equivalent to the following command:
213
214
215 cat start - middle /dev/null end > file
216
217
218
219
220 because the entire contents of the file would be consumed by cat the
221 first time − was used as a file operand and an end-of-file condition
222 would be detected immediately when −was referenced the second time.
223
224
226 See environ(5) for descriptions of the following environment variables
227 that affect the execution of cat: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES,
228 and NLSPATH.
229
231 The following exit values are returned:
232
233 0 All input files were output successfully.
234
235
236 >0 An error occurred.
237
238
240 See attributes(5) for descriptions of the following attributes:
241
242 /usr/bin/cat
243 ┌─────────────────────────────┬─────────────────────────────┐
244 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
245 ├─────────────────────────────┼─────────────────────────────┤
246 │Availability │SUNWcsu │
247 ├─────────────────────────────┼─────────────────────────────┤
248 │CSI │Enabled │
249 ├─────────────────────────────┼─────────────────────────────┤
250 │Interface Stability │Committed │
251 ├─────────────────────────────┼─────────────────────────────┤
252 │Standard │See standards(5). │
253 └─────────────────────────────┴─────────────────────────────┘
254
255 ksh93
256 ┌─────────────────────────────┬─────────────────────────────┐
257 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
258 ├─────────────────────────────┼─────────────────────────────┤
259 │Availability │SUNWcsu │
260 ├─────────────────────────────┼─────────────────────────────┤
261 │Interface Stability │See below. │
262 └─────────────────────────────┴─────────────────────────────┘
263
264
265 The ksh93 built-in binding to /bin and /usr/bin is Volatile. The built-
266 in interfaces are Uncommitted.
267
269 touch(1), attributes(5), environ(5), largefile(5), standards(5)
270
272 Redirecting the output of cat onto one of the files being read causes
273 the loss of the data originally in the file being read. For example,
274
275 example% cat filename1 filename2 > filename1
276
277
278
279
280 causes the original data in filename1 to be lost.
281
282
283
284SunOS 5.11 8 Apr 2008 cat(1)