1 '\" te 2 .\" Copyright 1989 AT&T Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 2005, Sun Microsystems, Inc. All Rights Reserved 3 .\" 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 4 .\" http://www.opengroup.org/bookstore/. 5 .\" 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. 6 .\" This notice shall appear on any product containing this material. 7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. 8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. 9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] 10 .\" Copyright (c) 2013, Joyent, Inc. All Rights Reserved. 11 .TH TAIL 1 "Jan 18, 2013" 12 .SH NAME 13 tail \- deliver the last part of a file 14 .SH SYNOPSIS 15 .LP 16 .nf 17 \fB/usr/bin/tail\fR [\(+-s \fInumber\fR [lbcr]] [\fIfile\fR] 18 .fi 19 20 .LP 21 .nf 22 \fB/usr/bin/tail\fR [\fB-lbcr\fR] [\fIfile\fR] 23 .fi 24 25 .LP 26 .nf 27 \fB/usr/bin/tail\fR [\(+- \fInumber\fR [lbcfF]] [\fIfile\fR] 28 .fi 29 30 .LP 31 .nf 32 \fB/usr/bin/tail\fR [\fB-lbcfF\fR] [\fIfile\fR] 33 .fi 34 35 .LP 36 .nf 37 \fB/usr/xpg4/bin/tail\fR [\fB-f\fR | \fB-r\fR] [\fB-c\fR \fInumber\fR | \fB-n\fR \fInumber\fR] [\fIfile\fR] 38 .fi 39 40 .LP 41 .nf 42 \fB/usr/xpg4/bin/tail\fR [\(+- \fInumber\fR [l | b | c] [f]] [\fIfile\fR] 43 .fi 44 45 .LP 46 .nf 47 \fB/usr/xpg4/bin/tail\fR [\(+- \fInumber\fR [l] [f | r]] [\fIfile\fR] 48 .fi 49 50 .SH DESCRIPTION 51 .sp 52 .LP 53 The \fBtail\fR utility copies the named file to the standard output beginning 54 at a designated place. If no file is named, the standard input is used. 55 .sp 56 .LP 57 Copying begins at a point in the file indicated by the \fB-c\fR\fInumber\fR, 58 \fB-n\fR\fInumber\fR, or \fB\(+-\fR\fInumber\fR options (if \fB+\fR\fInumber\fR 59 is specified, begins at distance number from the beginning; if 60 \fB-\fR\fInumber\fR is specified, from the end of the input; if \fInumber\fR is 61 \fINULL\fR, the value \fB10\fR is assumed). \fInumber\fR is counted in units of 62 lines or byte according to the \fB-c\fR \fB or \fR \fB-n\fR options, or lines, 63 blocks, or bytes, according to the appended option \fBl\fR, \fBb\fR, or 64 \fBc\fR. When no units are specified, counting is by lines. 65 .SH OPTIONS 66 .sp 67 .LP 68 The following options are supported for both \fB/usr/bin/tail\fR and 69 \fB/usr/xpg4/bin/tail\fR. The \fB-r\fR and \fB-f\fR options are mutually 70 exclusive. If both are specified on the command line, the \fB-f\fR option is 71 ignored. 72 .sp 73 .ne 2 74 .na 75 \fB\fB-b\fR \fR 76 .ad 77 .RS 7n 78 Units of blocks. 79 .RE 80 81 .sp 82 .ne 2 83 .na 84 \fB\fB-c\fR \fR 85 .ad 86 .RS 7n 87 Units of bytes. 88 .RE 89 90 .sp 91 .ne 2 92 .na 93 \fB\fB-f\fR \fR 94 .ad 95 .RS 7n 96 Follow. If the input-file is not a pipe, \fBtail\fR does not terminate after 97 the last line of the input-file has been copied, but enters an endless loop, 98 wherein it watches the file for modifications and attempts to read and copy 99 further records from the input-file. Thus it can be used to monitor the growth 100 of a file that is being written by some other process. If the watched file is 101 truncated \fBtail\fR will begin reading records from the start of the file. 102 .RE 103 104 .sp 105 .ne 2 106 .na 107 \fB\fB-F\fR \fR 108 .ad 109 .RS 7n 110 Follow named file. Operates as with \fB-f\fR, except that if the file is moved 111 (e.g. if a watched log file is rotated) \fBtail\fR will close the original file 112 and begin reading records from the start of the file with the specified name 113 if and when that file is recreated. 114 .RE 115 116 .sp 117 .ne 2 118 .na 119 \fB\fB-l\fR \fR 120 .ad 121 .RS 7n 122 Units of lines. 123 .RE 124 125 .sp 126 .ne 2 127 .na 128 \fB\fB-r\fR \fR 129 .ad 130 .RS 7n 131 Reverse. Copies lines from the specified starting point in the file in reverse 132 order. The default for \fBr\fR is to print the entire file in reverse order. 133 .RE 134 135 .SS "/usr/xpg4/bin/tail" 136 .sp 137 .LP 138 The following options are supported for \fB/usr/xpg4/bin/tail\fR only: 139 .sp 140 .ne 2 141 .na 142 \fB\fB-c\fR \fInumber\fR \fR 143 .ad 144 .RS 14n 145 The \fInumber\fR option-argument must be a decimal integer whose sign affects 146 the location in the file, measured in bytes, to begin the copying: 147 .sp 148 .ne 2 149 .na 150 \fB\fB+\fR \fR 151 .ad 152 .RS 9n 153 Copying starts relative to the beginning of the file. 154 .RE 155 156 .sp 157 .ne 2 158 .na 159 \fB\fB\(mi\fR \fR 160 .ad 161 .RS 9n 162 Copying starts relative to the end of the file. 163 .RE 164 165 .sp 166 .ne 2 167 .na 168 \fBnone\fR 169 .ad 170 .RS 9n 171 Copying starts relative to the end of the file. 172 .RE 173 174 The origin for counting is 1; that is, \fB\fR\fB-c\fR\fB+1\fR represents the 175 first byte of the file, \fB\fR\fB-c\fR\fB\(mi1\fR the last. 176 .RE 177 178 .sp 179 .ne 2 180 .na 181 \fB\fB-n\fR \fInumber\fR \fR 182 .ad 183 .RS 14n 184 Equivalent to \fB-c\fR\fInumber,\fR except the starting location in the file is 185 measured in lines instead of bytes. The origin for counting is \fB1\fR. That 186 is, \fB-n\fR\fB+1\fR represents the first line of the file, \fB-n\fR\fB\(mi1\fR 187 the last. 188 .RE 189 190 .SH OPERANDS 191 .sp 192 .LP 193 The following operand is supported: 194 .sp 195 .ne 2 196 .na 197 \fB\fIfile\fR \fR 198 .ad 199 .RS 9n 200 A path name of an input file. If no \fIfile\fR operands are specified, the 201 standard input is used. 202 .RE 203 204 .SH USAGE 205 .sp 206 .LP 207 See \fBlargefile\fR(5) for the description of the behavior of \fBtail\fR when 208 encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). 209 .SH EXAMPLES 210 .LP 211 \fBExample 1 \fRUsing the tail Command 212 .sp 213 .LP 214 The following command prints the last ten lines of the file \fBfred\fR, 215 followed by any lines that are appended to \fBfred\fR between the time 216 \fBtail\fR is initiated and killed. 217 218 .sp 219 .in +2 220 .nf 221 example% \fBtail -f fred\fR 222 .fi 223 .in -2 224 .sp 225 226 .sp 227 .LP 228 The next command prints the last 15 bytes of the file \fBfred\fR, followed by 229 any lines that are appended to \fBfred\fR between the time \fBtail\fR is 230 initiated and killed: 231 232 .sp 233 .in +2 234 .nf 235 example% \fBtail -15cf fred\fR 236 .fi 237 .in -2 238 .sp 239 240 .SH ENVIRONMENT VARIABLES 241 .sp 242 .LP 243 See \fBenviron\fR(5) for descriptions of the following environment variables 244 that affect the execution of \fBtail\fR: \fBLANG\fR, \fBLC_ALL\fR, 245 \fBLC_CTYPE\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR. 246 .SH EXIT STATUS 247 .sp 248 .LP 249 The following exit values are returned: 250 .sp 251 .ne 2 252 .na 253 \fB\fB0\fR \fR 254 .ad 255 .RS 7n 256 Successful completion. 257 .RE 258 259 .sp 260 .ne 2 261 .na 262 \fB\fB>0\fR \fR 263 .ad 264 .RS 7n 265 An error occurred. 266 .RE 267 268 .SH ATTRIBUTES 269 .sp 270 .LP 271 See \fBattributes\fR(5) for descriptions of the following attributes: 272 .SS "/usr/bin/tail" 273 .sp 274 275 .sp 276 .TS 277 box; 278 c | c 279 l | l . 280 ATTRIBUTE TYPE ATTRIBUTE VALUE 281 _ 282 CSI Enabled 283 .TE 284 285 .SS "/usr/xpg4/bin/tail" 286 .sp 287 288 .sp 289 .TS 290 box; 291 c | c 292 l | l . 293 ATTRIBUTE TYPE ATTRIBUTE VALUE 294 _ 295 CSI Enabled 296 _ 297 Interface Stability Standard 298 .TE 299 300 .SH SEE ALSO 301 .sp 302 .LP 303 \fBcat\fR(1), \fBhead\fR(1), \fBmore\fR(1), \fBpg\fR(1), \fBdd\fR(1M), 304 \fBattributes\fR(5), \fBenviron\fR(5), \fBlargefile\fR(5), \fBstandards\fR(5) 305 .SH NOTES 306 .sp 307 .LP 308 Piped tails relative to the end of the file are stored in a buffer, and thus 309 are limited in length. Various kinds of anomalous behavior can happen with 310 character special files.