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