'\" te .\" Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at http://www.opengroup.org/bookstore/. .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html. This notice shall appear on any product containing this material. .TH cat 1 "25 Jul 2011" "SunOS 5.11" "User Commands" .SH NAME cat \- concatenate and display files .SH SYNOPSIS .LP .nf \fB/usr/bin/cat\fR [\fB-nbsuvet\fR] [\fIfile\fR...] .fi .SH DESCRIPTION .sp .LP The \fBcat\fR utility reads each \fIfile\fR in sequence and writes it on the standard output. Thus: .sp .in +2 .nf example% \fBcat file\fR .fi .in -2 .sp .sp .LP prints \fIfile\fR on your terminal, and: .sp .in +2 .nf example% \fBcat file1 file2 >file3\fR .fi .in -2 .sp .sp .LP concatenates \fIfile1\fR and \fIfile2\fR, and writes the results in \fIfile3\fR. If no input file is given, \fBcat\fR reads from the standard input file. .SH OPTIONS .sp .LP The following options are supported by \fB/usr/bin/cat\fR: .sp .ne 2 .mk .na \fB\fB-b\fR\fR .ad .RS 6n .rt Number the lines, as \fB-n\fR, but omit the line numbers from blank lines. .RE .sp .ne 2 .mk .na \fB\fB-n\fR\fR .ad .RS 6n .rt Precede each line output with its line number. .RE .sp .ne 2 .mk .na \fB\fB-s\fR\fR .ad .RS 6n .rt \fBcat\fR is silent about non-existent files. .RE .sp .ne 2 .mk .na \fB\fB-u\fR\fR .ad .RS 6n .rt The output is not buffered. .sp Buffered output is the default. .RE .sp .ne 2 .mk .na \fB\fB-v\fR\fR .ad .RS 6n .rt Non-printing characters, with the exception of tabs, NEWLINEs and form feeds, are printed visibly. ASCII control characters (octal \fB000\fR \(mi \fB037\fR) are printed as \fB^\fR\fIn,\fR where \fIn\fR is the corresponding ASCII character in the range octal 100 \(mi 137 (@, A, B, C, . . ., X, Y, Z, [, \e, ], ^, and _); the \fBDEL\fR character (octal \fB0177\fR) is printed \fB^?\fR. Other non-printable characters are printed as \fBM-\fR\fIx,\fR where \fIx\fR is the ASCII character specified by the low-order seven bits. .RE .sp .LP When used with the \fB-v\fR option, the following options can be used: .sp .ne 2 .mk .na \fB\fB-e\fR\fR .ad .RS 6n .rt A \fB$\fR character is printed at the end of each line, prior to the NEWLINE. .RE .sp .ne 2 .mk .na \fB\fB-t\fR\fR .ad .RS 6n .rt Tabs are printed as \fB^I\fRs and form feeds to be printed as \fB^L\fRs. .RE .sp .LP The \fB-e\fR and \fB-t\fR options are ignored if the \fB-v\fR option is not specified. .SH OPERANDS .sp .LP The following operand is supported: .sp .ne 2 .mk .na \fB\fIfile\fR\fR .ad .RS 8n .rt A path name of an input file. If no \fIfile\fR is specified, the standard input is used. If \fIfile\fR is \fB\|\(mi\|\fR, \fBcat\fR reads from the standard input at that point in the sequence. \fBcat\fR does not close and reopen standard input when it is referenced in this way, but accepts multiple occurrences of \fB\|\(mi\|\fR as \fIfile\fR. .RE .SH USAGE .sp .LP See \fBlargefile\fR(5) for the description of the behavior of \fBcat\fR when encountering files greater than or equal to 2 Gbyte (2^31 bytes). .SH EXAMPLES .LP \fBExample 1 \fRConcatenating a File .sp .LP The following command writes the contents of the file \fBmyfile\fR to standard output: .sp .in +2 .nf example% \fBcat myfile\fR .fi .in -2 .sp .LP \fBExample 2 \fRConcatenating Two files into One .sp .LP The following command concatenates the files \fBdoc1\fR and \fBdoc2\fR and writes the result to \fBdoc.all\fR. .sp .in +2 .nf example% \fBcat doc1 doc2 > doc.all\fR .fi .in -2 .sp .LP \fBExample 3 \fRConcatenating Two Arbitrary Pieces of Input with a Single Invocation .sp .LP When standard input is a terminal, the following command gets two arbitrary pieces of input from the terminal with a single invocation of \fBcat\fR: .sp .in +2 .nf example% \fBcat start - middle - end > file\fR .fi .in -2 .sp .sp .LP when standard input is a terminal, gets two arbitrary pieces of input from the terminal with a single invocation of \fBcat\fR. .sp .LP If standard input is a regular file, .sp .in +2 .nf example% \fBcat start - middle - end > file\fR .fi .in -2 .sp .sp .LP would be equivalent to the following command: .sp .in +2 .nf \fBcat start - middle /dev/null end > file\fR .fi .in -2 .sp .sp .LP because the entire contents of the file would be consumed by \fBcat\fR the first time \fB\|\(mi\|\fR was used as a \fIfile\fR operand and an end-of-file condition would be detected immediately when \fB\|\(mi\|\fRwas referenced the second time. .SH ENVIRONMENT VARIABLES .sp .LP See \fBenviron\fR(5) for descriptions of the following environment variables that affect the execution of \fBcat\fR: \fBLANG\fR, \fBLC_ALL\fR, \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. .SH EXIT STATUS .sp .LP The following exit values are returned: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt All input files were output successfully. .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt An error occurred. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Availabilitysystem/core-os _ CSIEnabled _ Interface StabilityCommitted _ StandardSee \fBstandards\fR(5). .TE .SH SEE ALSO .sp .LP \fBtouch\fR(1), \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5) .SH NOTES .sp .LP Redirecting the output of \fBcat\fR onto one of the files being read causes the loss of the data originally in the file being read. For example, .sp .in +2 .nf example% \fBcat filename1 filename2 > filename1\fR .fi .in -2 .sp .sp .LP causes the original data in \fBfilename1\fR to be lost.