19ddb49cbSWarner Losh.\"- 24b88c807SRodney W. Grimes.\" Copyright (c) 1989, 1990, 1993 34b88c807SRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 44b88c807SRodney W. Grimes.\" 54b88c807SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 64b88c807SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc. 74b88c807SRodney W. Grimes.\" 84b88c807SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 94b88c807SRodney W. Grimes.\" modification, are permitted provided that the following conditions 104b88c807SRodney W. Grimes.\" are met: 114b88c807SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 124b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 134b88c807SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 144b88c807SRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 154b88c807SRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 16fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors 174b88c807SRodney W. Grimes.\" may be used to endorse or promote products derived from this software 184b88c807SRodney W. Grimes.\" without specific prior written permission. 194b88c807SRodney W. Grimes.\" 204b88c807SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 214b88c807SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 224b88c807SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 234b88c807SRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 244b88c807SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 254b88c807SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 264b88c807SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 274b88c807SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 284b88c807SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 294b88c807SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 304b88c807SRodney W. Grimes.\" SUCH DAMAGE. 314b88c807SRodney W. Grimes.\" 32e38120d4SJoel Dahl.Dd January 29, 2013 334b88c807SRodney W. Grimes.Dt CAT 1 342192b407SJeroen Ruigrok van der Werven.Os 354b88c807SRodney W. Grimes.Sh NAME 364b88c807SRodney W. Grimes.Nm cat 374b88c807SRodney W. Grimes.Nd concatenate and print files 384b88c807SRodney W. Grimes.Sh SYNOPSIS 39be8b1497SRuslan Ermilov.Nm 40aece80a2SBrooks Davis.Op Fl belnstuv 414b88c807SRodney W. Grimes.Op Ar 424b88c807SRodney W. Grimes.Sh DESCRIPTION 434b88c807SRodney W. GrimesThe 444c95995fSPhilippe Charnier.Nm 454b88c807SRodney W. Grimesutility reads files sequentially, writing them to the standard output. 464b88c807SRodney W. GrimesThe 474b88c807SRodney W. Grimes.Ar file 482192b407SJeroen Ruigrok van der Wervenoperands are processed in command-line order. 492192b407SJeroen Ruigrok van der WervenIf 502192b407SJeroen Ruigrok van der Werven.Ar file 512192b407SJeroen Ruigrok van der Wervenis a single dash 52d2b53efbSRuslan Ermilov.Pq Sq Fl 532192b407SJeroen Ruigrok van der Wervenor absent, 542192b407SJeroen Ruigrok van der Werven.Nm 550ec8be84SRuslan Ermilovreads from the standard input. 560ec8be84SRuslan ErmilovIf 57cbf2d71fSMatthew Dillon.Ar file 580ec8be84SRuslan Ermilovis a 590ec8be84SRuslan Ermilov.Ux 600ec8be84SRuslan Ermilovdomain socket, 61cbf2d71fSMatthew Dillon.Nm 620ec8be84SRuslan Ermilovconnects to it and then reads it until 630ec8be84SRuslan Ermilov.Dv EOF . 640ec8be84SRuslan ErmilovThis complements the 650ec8be84SRuslan Ermilov.Ux 660ec8be84SRuslan Ermilovdomain binding capability available in 670ec8be84SRuslan Ermilov.Xr inetd 8 . 684b88c807SRodney W. Grimes.Pp 694b88c807SRodney W. GrimesThe options are as follows: 7012f93eb9SPhilippe Charnier.Bl -tag -width indent 714b88c807SRodney W. Grimes.It Fl b 7212f93eb9SPhilippe CharnierNumber the non-blank output lines, starting at 1. 734b88c807SRodney W. Grimes.It Fl e 7412f93eb9SPhilippe CharnierDisplay non-printing characters (see the 754b88c807SRodney W. Grimes.Fl v 7612f93eb9SPhilippe Charnieroption), and display a dollar sign 774b88c807SRodney W. Grimes.Pq Ql \&$ 7812f93eb9SPhilippe Charnierat the end of each line. 79aece80a2SBrooks Davis.It Fl l 80aece80a2SBrooks DavisSet an exclusive advisory lock on the standard output file descriptor. 81aece80a2SBrooks DavisThis lock is set using 82aece80a2SBrooks Davis.Xr fcntl 2 83aece80a2SBrooks Daviswith the 84aece80a2SBrooks Davis.Dv F_SETLKW 85aece80a2SBrooks Daviscommand. 86aece80a2SBrooks DavisIf the output file is already locked, 87aece80a2SBrooks Davis.Nm 88aece80a2SBrooks Daviswill block until the lock is acquired. 894b88c807SRodney W. Grimes.It Fl n 90890acb95SSteve PriceNumber the output lines, starting at 1. 914b88c807SRodney W. Grimes.It Fl s 924b88c807SRodney W. GrimesSqueeze multiple adjacent empty lines, causing the output to be 934b88c807SRodney W. Grimessingle spaced. 944b88c807SRodney W. Grimes.It Fl t 9512f93eb9SPhilippe CharnierDisplay non-printing characters (see the 964b88c807SRodney W. Grimes.Fl v 9712f93eb9SPhilippe Charnieroption), and display tab characters as 9812f93eb9SPhilippe Charnier.Ql ^I . 994b88c807SRodney W. Grimes.It Fl u 100744e4bbaSTim J. RobbinsDisable output buffering. 1014b88c807SRodney W. Grimes.It Fl v 1024c95995fSPhilippe CharnierDisplay non-printing characters so they are visible. 1034b88c807SRodney W. GrimesControl characters print as 1044b88c807SRodney W. Grimes.Ql ^X 1054b88c807SRodney W. Grimesfor control-X; the delete 1064b88c807SRodney W. Grimescharacter (octal 0177) prints as 10712e720d7SRuslan Ermilov.Ql ^? . 1084c95995fSPhilippe Charnier.Pf Non- Tn ASCII 1094c95995fSPhilippe Charniercharacters (with the high bit set) are printed as 1104b88c807SRodney W. Grimes.Ql M- 1114b88c807SRodney W. Grimes(for meta) followed by the character for the low 7 bits. 1124b88c807SRodney W. Grimes.El 1136fca4c7cSRuslan Ermilov.Sh EXIT STATUS 114d628d776SRuslan Ermilov.Ex -std 1152192b407SJeroen Ruigrok van der Werven.Sh EXAMPLES 1162192b407SJeroen Ruigrok van der WervenThe command: 1176a5796e7SRuslan Ermilov.Pp 1186a5796e7SRuslan Ermilov.Dl "cat file1" 1192192b407SJeroen Ruigrok van der Werven.Pp 1202192b407SJeroen Ruigrok van der Wervenwill print the contents of 12117bba29bSRuslan Ermilov.Pa file1 1222192b407SJeroen Ruigrok van der Wervento the standard output. 1232192b407SJeroen Ruigrok van der Werven.Pp 1242192b407SJeroen Ruigrok van der WervenThe command: 1256a5796e7SRuslan Ermilov.Pp 1266a5796e7SRuslan Ermilov.Dl "cat file1 file2 > file3" 1272192b407SJeroen Ruigrok van der Werven.Pp 1282192b407SJeroen Ruigrok van der Wervenwill sequentially print the contents of 12917bba29bSRuslan Ermilov.Pa file1 1302192b407SJeroen Ruigrok van der Wervenand 13117bba29bSRuslan Ermilov.Pa file2 1322192b407SJeroen Ruigrok van der Wervento the file 13317bba29bSRuslan Ermilov.Pa file3 , 1342192b407SJeroen Ruigrok van der Werventruncating 13517bba29bSRuslan Ermilov.Pa file3 1362192b407SJeroen Ruigrok van der Wervenif it already exists. 137d11ed2f6SKevin LoSee the manual page for your shell (e.g., 1382192b407SJeroen Ruigrok van der Werven.Xr sh 1 ) 1392192b407SJeroen Ruigrok van der Wervenfor more information on redirection. 1402192b407SJeroen Ruigrok van der Werven.Pp 1412192b407SJeroen Ruigrok van der WervenThe command: 1426a5796e7SRuslan Ermilov.Pp 1436a5796e7SRuslan Ermilov.Dl "cat file1 - file2 - file3" 1442192b407SJeroen Ruigrok van der Werven.Pp 1452192b407SJeroen Ruigrok van der Wervenwill print the contents of 14617bba29bSRuslan Ermilov.Pa file1 , 1472192b407SJeroen Ruigrok van der Wervenprint data it receives from the standard input until it receives an 1482192b407SJeroen Ruigrok van der Werven.Dv EOF 1492192b407SJeroen Ruigrok van der Werven.Pq Sq ^D 1502192b407SJeroen Ruigrok van der Wervencharacter, print the contents of 15117bba29bSRuslan Ermilov.Pa file2 , 1522192b407SJeroen Ruigrok van der Wervenread and output contents of the standard input again, then finally output 1532192b407SJeroen Ruigrok van der Werventhe contents of 15417bba29bSRuslan Ermilov.Pa file3 . 155*10b84b88SZhan-WeiNote that if the standard input refers to a file, the second dash 1562192b407SJeroen Ruigrok van der Wervenon the command-line would have no effect, since the entire contents of the file 1572192b407SJeroen Ruigrok van der Wervenwould have already been read and printed by 1582192b407SJeroen Ruigrok van der Werven.Nm 1592192b407SJeroen Ruigrok van der Wervenwhen it encountered the first 16017bba29bSRuslan Ermilov.Sq Fl 1612192b407SJeroen Ruigrok van der Wervenoperand. 1624b88c807SRodney W. Grimes.Sh SEE ALSO 1634b88c807SRodney W. Grimes.Xr head 1 , 1644b88c807SRodney W. Grimes.Xr more 1 , 1654b88c807SRodney W. Grimes.Xr pr 1 , 1662192b407SJeroen Ruigrok van der Werven.Xr sh 1 , 167890acb95SSteve Price.Xr tail 1 , 1682192b407SJeroen Ruigrok van der Werven.Xr vis 1 , 1690f777991SDima Dorfman.Xr zcat 1 , 170aece80a2SBrooks Davis.Xr fcntl 2 , 1712192b407SJeroen Ruigrok van der Werven.Xr setbuf 3 1724b88c807SRodney W. Grimes.Rs 1734b88c807SRodney W. Grimes.%A Rob Pike 1744b88c807SRodney W. Grimes.%T "UNIX Style, or cat -v Considered Harmful" 1754b88c807SRodney W. Grimes.%J "USENIX Summer Conference Proceedings" 1764b88c807SRodney W. Grimes.%D 1983 1774b88c807SRodney W. Grimes.Re 1782192b407SJeroen Ruigrok van der Werven.Sh STANDARDS 1792192b407SJeroen Ruigrok van der WervenThe 1802192b407SJeroen Ruigrok van der Werven.Nm 1812192b407SJeroen Ruigrok van der Wervenutility is compliant with the 1822192b407SJeroen Ruigrok van der Werven.St -p1003.2-92 1832192b407SJeroen Ruigrok van der Wervenspecification. 1842192b407SJeroen Ruigrok van der Werven.Pp 1852192b407SJeroen Ruigrok van der WervenThe flags 186aece80a2SBrooks Davis.Op Fl belnstv 1872192b407SJeroen Ruigrok van der Wervenare extensions to the specification. 1884b88c807SRodney W. Grimes.Sh HISTORY 1894b88c807SRodney W. GrimesA 1904b88c807SRodney W. Grimes.Nm 1912192b407SJeroen Ruigrok van der Wervenutility appeared in 1922192b407SJeroen Ruigrok van der Werven.At v1 . 1934c95995fSPhilippe Charnier.An Dennis Ritchie 1944c95995fSPhilippe Charnierdesigned and wrote the first man page. 195f3aff7c9SBenjamin KadukIt appears to have been for 196f3aff7c9SBenjamin Kaduk.Nm . 1972192b407SJeroen Ruigrok van der Werven.Sh BUGS 1982192b407SJeroen Ruigrok van der WervenBecause of the shell language mechanism used to perform output 1992192b407SJeroen Ruigrok van der Wervenredirection, the command 2005091080eSSheldon Hearn.Dq Li cat file1 file2 > file1 20117bba29bSRuslan Ermilovwill cause the original data in 20217bba29bSRuslan Ermilov.Pa file1 20317bba29bSRuslan Ermilovto be destroyed! 204f74d4353STim J. Robbins.Pp 205f74d4353STim J. RobbinsThe 206f74d4353STim J. Robbins.Nm 207f74d4353STim J. Robbinsutility does not recognize multibyte characters when the 208f74d4353STim J. Robbins.Fl t 209f74d4353STim J. Robbinsor 210f74d4353STim J. Robbins.Fl v 211f74d4353STim J. Robbinsoption is in effect. 212