2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
46 .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
48 .TH CAT 1 "Apr 8, 2008"
50 cat \- concatenate and display files
52 .SS "\fB/usr/bin/cat\fR"
55 \fB/usr/bin/cat\fR [\fB-nbsuvet\fR] [\fIfile\fR...]
61 \fBcat\fR [\fB-bdenstuvABDEST\fR] [\fIfile\fR...]
65 .SS "\fB/usr/bin/cat\fR"
68 The \fBcat\fR utility reads each \fIfile\fR in sequence and writes it on the
69 standard output. Thus:
73 example% \fBcat file\fR
80 prints \fIfile\fR on your terminal, and:
84 example% \fBcat file1 file2 >file3\fR
91 concatenates \fIfile1\fR and \fIfile2\fR, and writes the results in
92 \fIfile3\fR. If no input file is given, \fBcat\fR reads from the standard input
97 The \fBcat\fR built-in in \fBksh93\fR is associated with the \fB/bin\fR and
98 \fB/usr/bin\fR paths. It is invoked when \fBcat\fR is executed without a
99 pathname prefix and the pathname search finds a \fB/bin/cat\fR or
100 \fB/usr/bin/cat\fR executable. \fBcat\fR copies each file in sequence to the
101 standard output. If no file is specified, or if the file is \fB-\fR, \fBcat\fR
102 copies from standard input starting at the current location.
104 .SS "\fB/usr/bin/cat\fR"
107 The following options are supported by \fB/usr/bin/cat\fR:
114 Number the lines, as \fB-n\fR, but omit the line numbers from blank lines.
123 Precede each line output with its line number.
132 \fBcat\fR is silent about non-existent files.
141 The output is not buffered.
143 Buffered output is the default.
152 Non-printing characters, with the exception of tabs, NEWLINEs and form feeds,
153 are printed visibly. ASCII control characters (octal \fB000\fR \(mi \fB037\fR)
154 are printed as \fB^\fR\fIn,\fR where \fIn\fR is the corresponding ASCII
155 character in the range octal 100 \(mi 137 (@, A, B, C, ..., X, Y, Z, [, \e,
156 ], ^, and _); the \fBDEL\fR character (octal \fB0177\fR) is printed \fB^?\fR.
157 Other non-printable characters are printed as \fBM-\fR\fIx,\fR where \fIx\fR is
158 the ASCII character specified by the low-order seven bits.
163 When used with the \fB-v\fR option, the following options can be used:
170 A \fB$\fR character is printed at the end of each line, prior to the NEWLINE.
179 Tabs are printed as \fB^I\fRs and form feeds to be printed as \fB^L\fRs.
184 The \fB-e\fR and \fB-t\fR options are ignored if the \fB-v\fR option is not
189 \fBksh93\fR \fBcat\fR supports the following options:
193 \fB\fB-b\fR \fB--number-nonblank\fR\fR
196 Number lines as with \fB-n\fR but omit line numbers from blank lines.
202 \fB\fB-d\fR \fB--dos-input\fR\fR
205 Open input files in text mode. Removes RETURNs in front of NEWLINEs on some
215 Equivalent to \fB-vE\fR.
221 \fB\fB-n\fR \fB--number\fR\fR
224 Insert a line number at the beginning of each line.
233 Equivalent to \fB-S\fR for \fBatt universe\fR and \fB-B\fR otherwise.
242 Equivalent to \fB-vT\fR.
248 \fB\fB-u\fR \fB--unbuffer\fR\fR
251 Do not delay the output by buffering.
257 \fB\fB-v\fR \fB--show-nonprinting\fR\fR
260 Cause non-printing characters (with the exception of TABs, NEWLINEs, and form
261 feeds) to be output as printable character sequences. \fBASCII\fR control
262 characters are printed as \fB^n\fR, where \fIn\fR is the corresponding
263 \fBASCII\fR character in the range octal \fB100\fR-\fB137\fR. The DEL character
264 (octal \fB0177\fR) is copied as \fB^?\fR. Other non-printable characters are
265 copied as \fBM-\fR\fIx\fR where \fIx\fR is the \fBASCII\fR character specified
266 by the low-order seven bits. Multi-byte characters in the current locale are
267 treated as printable characters.
273 \fB\fB-A\fR \fB--show-all\fR\fR
276 Equivalent to \fB-vET\fR.
282 \fB\fB-B\fR \fB--squeeze-blank\fR\fR
285 Replace multiple adjacent NEWLINE characters with one NEWLINE.
291 \fB\fB-D\fR \fB--dos-output\fR\fR
294 Open output files in text mode. Insert RETURNs in front of NEWLINEs on some
301 \fB\fB-E\fR \fB--show-ends\fR\fR
304 Insert a \fB$\fR before each NEWLINE.
310 \fB\fB-S\fR \fB--silent\fR\fR
313 \fBcat\fR is silent about non-existent files.
319 \fB\fB-T\fR \fB--show-blank\fR\fR
322 Copies TABs as \fB^I\fR and form feeds as \fB^L\fR.
328 The following operand is supported:
335 A path name of an input file. If no \fIfile\fR is specified, the standard input
336 is used. If \fIfile\fR is \fB\|\(mi\|\fR, \fBcat\fR reads from the standard
337 input at that point in the sequence. \fBcat\fR does not close and reopen
338 standard input when it is referenced in this way, but accepts multiple
339 occurrences of \fB\|\(mi\|\fR as \fIfile\fR.
345 See \fBlargefile\fR(5) for the description of the behavior of \fBcat\fR when
346 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes).
349 \fBExample 1 \fRConcatenating a File
352 The following command writes the contents of the file \fBmyfile\fR to standard
358 example% \fBcat myfile\fR
364 \fBExample 2 \fRConcatenating Two files into One
367 The following command concatenates the files \fBdoc1\fR and \fBdoc2\fR and
368 writes the result to \fBdoc.all\fR.
373 example% \fBcat doc1 doc2 > doc.all\fR
379 \fBExample 3 \fRConcatenating Two Arbitrary Pieces of Input with a Single
383 When standard input is a terminal, the following command gets two arbitrary
384 pieces of input from the terminal with a single invocation of \fBcat\fR:
389 example% \fBcat start - middle - end > file\fR
396 when standard input is a terminal, gets two arbitrary pieces of input from the
397 terminal with a single invocation of \fBcat\fR.
401 If standard input is a regular file,
406 example% \fBcat start - middle - end > file\fR
413 would be equivalent to the following command:
418 \fBcat start - middle /dev/null end > file\fR
425 because the entire contents of the file would be consumed by \fBcat\fR the
426 first time \fB\|\(mi\|\fR was used as a \fIfile\fR operand and an end-of-file
427 condition would be detected immediately when \fB\|\(mi\|\fRwas referenced the
430 .SH ENVIRONMENT VARIABLES
433 See \fBenviron\fR(5) for descriptions of the following environment variables
434 that affect the execution of \fBcat\fR: \fBLANG\fR, \fBLC_ALL\fR,
435 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
439 The following exit values are returned:
446 All input files were output successfully.
461 See \fBattributes\fR(5) for descriptions of the following attributes:
462 .SS "\fB/usr/bin/cat\fR"
470 ATTRIBUTE TYPE ATTRIBUTE VALUE
474 Interface Stability Committed
476 Standard See \fBstandards\fR(5).
487 ATTRIBUTE TYPE ATTRIBUTE VALUE
489 Interface Stability See below.
494 The \fBksh93\fR built-in binding to \fB/bin\fR and \fB/usr/bin\fR is Volatile.
495 The built-in interfaces are Uncommitted.
499 \fBtouch\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5),
504 Redirecting the output of \fBcat\fR onto one of the files being read causes the
505 loss of the data originally in the file being read. For example,
509 example% \fBcat filename1 filename2 > filename1\fR
516 causes the original data in \fBfilename1\fR to be lost.