|
| 1 | +.\" $NetBSD: cat.1,v 1.36 2012/11/10 18:41:10 wiz Exp $ |
| 2 | +.\" |
| 3 | +.\" Copyright (c) 1989, 1990, 1993 |
| 4 | +.\" The Regents of the University of California. All rights reserved. |
| 5 | +.\" |
| 6 | +.\" This code is derived from software contributed to Berkeley by |
| 7 | +.\" the Institute of Electrical and Electronics Engineers, Inc. |
| 8 | +.\" |
| 9 | +.\" Redistribution and use in source and binary forms, with or without |
| 10 | +.\" modification, are permitted provided that the following conditions |
| 11 | +.\" are met: |
| 12 | +.\" 1. Redistributions of source code must retain the above copyright |
| 13 | +.\" notice, this list of conditions and the following disclaimer. |
| 14 | +.\" 2. Redistributions in binary form must reproduce the above copyright |
| 15 | +.\" notice, this list of conditions and the following disclaimer in the |
| 16 | +.\" documentation and/or other materials provided with the distribution. |
| 17 | +.\" 3. Neither the name of the University nor the names of its contributors |
| 18 | +.\" may be used to endorse or promote products derived from this software |
| 19 | +.\" without specific prior written permission. |
| 20 | +.\" |
| 21 | +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 22 | +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 23 | +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 24 | +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 25 | +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 26 | +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 27 | +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 28 | +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 29 | +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 30 | +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 31 | +.\" SUCH DAMAGE. |
| 32 | +.\" |
| 33 | +.\" @(#)cat.1 8.3 (Berkeley) 5/2/95 |
| 34 | +.\" |
| 35 | +.Dd November 10, 2012 |
| 36 | +.Dt CAT 1 |
| 37 | +.Os |
| 38 | +.Sh NAME |
| 39 | +.Nm cat |
| 40 | +.Nd concatenate and print files |
| 41 | +.Sh SYNOPSIS |
| 42 | +.Nm |
| 43 | +.Op Fl beflnstuv |
| 44 | +.Op Fl B Ar bsize |
| 45 | +.Op Fl |
| 46 | +.Op Ar |
| 47 | +.Sh DESCRIPTION |
| 48 | +The |
| 49 | +.Nm |
| 50 | +utility reads files sequentially, writing them to the standard output. |
| 51 | +The |
| 52 | +.Ar file |
| 53 | +operands are processed in command line order. |
| 54 | +A single dash represents the standard input, |
| 55 | +and may appear multiple times in the |
| 56 | +.Ar file |
| 57 | +list. |
| 58 | +If no |
| 59 | +.Ar file |
| 60 | +operands are given, standard input is read. |
| 61 | +.Pp |
| 62 | +The word |
| 63 | +.Dq concatenate |
| 64 | +is just a verbose synonym for |
| 65 | +.Dq catenate . |
| 66 | +.Pp |
| 67 | +The options are as follows: |
| 68 | +.Bl -tag -width Ds |
| 69 | +.It Fl B Ar bsize |
| 70 | +Read with a buffer size of |
| 71 | +.Ar bsize |
| 72 | +bytes, instead of the default buffer size which is the blocksize of the |
| 73 | +output file. |
| 74 | +.It Fl b |
| 75 | +Implies the |
| 76 | +.Fl n |
| 77 | +option, but doesn't number blank lines. |
| 78 | +.It Fl e |
| 79 | +Implies the |
| 80 | +.Fl v |
| 81 | +option, and displays a dollar sign |
| 82 | +.Pq Ql \&$ |
| 83 | +at the end of each line |
| 84 | +as well. |
| 85 | +.It Fl f |
| 86 | +Only attempt to display regular files. |
| 87 | +.It Fl l |
| 88 | +Set an exclusive advisory lock on the standard output file descriptor. |
| 89 | +This lock is set using |
| 90 | +.Xr fcntl 2 |
| 91 | +with the |
| 92 | +.Dv F_SETLKW |
| 93 | +command. |
| 94 | +If the output file is already locked, |
| 95 | +.Nm |
| 96 | +will block until the lock is acquired. |
| 97 | +.It Fl n |
| 98 | +Number the output lines, starting at 1. |
| 99 | +.It Fl s |
| 100 | +Squeeze multiple adjacent empty lines, causing the output to be |
| 101 | +single spaced. |
| 102 | +.It Fl t |
| 103 | +Implies the |
| 104 | +.Fl v |
| 105 | +option, and displays tab characters as |
| 106 | +.Ql ^I |
| 107 | +as well. |
| 108 | +.It Fl u |
| 109 | +The |
| 110 | +.Fl u |
| 111 | +option guarantees that the output is unbuffered. |
| 112 | +.It Fl v |
| 113 | +Displays non-printing characters so they are visible. |
| 114 | +Control characters print as |
| 115 | +.Ql ^X |
| 116 | +for control-X; the delete |
| 117 | +character (octal 0177) prints as |
| 118 | +.Ql ^? . |
| 119 | +Non-ascii characters (with the high bit set) are printed as |
| 120 | +.Ql M- |
| 121 | +(for meta) followed by the character for the low 7 bits. |
| 122 | +.El |
| 123 | +.Sh EXIT STATUS |
| 124 | +The |
| 125 | +.Nm |
| 126 | +utility exits 0 on success, and \*[Gt]0 if an error occurs. |
| 127 | +.Sh EXAMPLES |
| 128 | +The command: |
| 129 | +.Bd -literal -offset indent |
| 130 | +.Ic cat file1 |
| 131 | +.Ed |
| 132 | +.Pp |
| 133 | +will print the contents of |
| 134 | +.Ar file1 |
| 135 | +to the standard output. |
| 136 | +.Pp |
| 137 | +The command: |
| 138 | +.Bd -literal -offset indent |
| 139 | +.Ic cat file1 file2 \*[Gt] file3 |
| 140 | +.Ed |
| 141 | +.Pp |
| 142 | +will sequentially print the contents of |
| 143 | +.Ar file1 |
| 144 | +and |
| 145 | +.Ar file2 |
| 146 | +to the file |
| 147 | +.Ar file3 , |
| 148 | +truncating |
| 149 | +.Ar file3 |
| 150 | +if it already exists. |
| 151 | +See the manual page for your shell (e.g., |
| 152 | +.Xr sh 1 ) |
| 153 | +for more information on redirection. |
| 154 | +.Pp |
| 155 | +The command: |
| 156 | +.Bd -literal -offset indent |
| 157 | +.Ic cat file1 - file2 - file3 |
| 158 | +.Ed |
| 159 | +.Pp |
| 160 | +will print the contents of |
| 161 | +.Ar file1 , |
| 162 | +print data it receives from the standard input until it receives an |
| 163 | +.Dv EOF |
| 164 | +.Pq Sq ^D |
| 165 | +character, print the contents of |
| 166 | +.Ar file2 , |
| 167 | +read and output contents of the standard input again, then finally output |
| 168 | +the contents of |
| 169 | +.Ar file3 . |
| 170 | +Note that if the standard input referred to a file, the second dash |
| 171 | +on the command-line would have no effect, since the entire contents of the file |
| 172 | +would have already been read and printed by |
| 173 | +.Nm |
| 174 | +when it encountered the first |
| 175 | +.Ql \&- |
| 176 | +operand. |
| 177 | +.Sh SEE ALSO |
| 178 | +.Xr head 1 , |
| 179 | +.Xr hexdump 1 , |
| 180 | +.Xr lpr 1 , |
| 181 | +.Xr more 1 , |
| 182 | +.Xr pr 1 , |
| 183 | +.Xr tail 1 , |
| 184 | +.Xr view 1 , |
| 185 | +.Xr vis 1 , |
| 186 | +.Xr fcntl 2 |
| 187 | +.Rs |
| 188 | +.%A Rob Pike |
| 189 | +.%T "UNIX Style, or cat -v Considered Harmful" |
| 190 | +.%J "USENIX Summer Conference Proceedings" |
| 191 | +.%D 1983 |
| 192 | +.Re |
| 193 | +.Sh STANDARDS |
| 194 | +The |
| 195 | +.Nm |
| 196 | +utility is expected to conform to the |
| 197 | +.St -p1003.2-92 |
| 198 | +specification. |
| 199 | +.Pp |
| 200 | +The flags |
| 201 | +.Op Fl belnstv |
| 202 | +are extensions to the specification. |
| 203 | +.Sh HISTORY |
| 204 | +A |
| 205 | +.Nm |
| 206 | +utility appeared in |
| 207 | +.At v1 . |
| 208 | +Dennis Ritchie designed and wrote the first man page. |
| 209 | +It appears to have been |
| 210 | +.Xr cat 1 . |
| 211 | +.Sh BUGS |
| 212 | +Because of the shell language mechanism used to perform output |
| 213 | +redirection, the command |
| 214 | +.Dq Li cat file1 file2 \*[Gt] file1 |
| 215 | +will cause the original data in file1 to be destroyed! |
| 216 | +This is performed by the shell before |
| 217 | +.Nm |
| 218 | +is run. |
0 commit comments