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