Annotation of src/usr.bin/tail/tail.1, Revision 1.10
1.10 ! aaron 1: .\" $OpenBSD: tail.1,v 1.9 2000/03/11 21:40:04 aaron Exp $
1.1 deraadt 2: .\" $NetBSD: tail.1,v 1.4 1994/11/23 07:42:13 jtc Exp $
3: .\"
4: .\" Copyright (c) 1980, 1990, 1991, 1993
5: .\" The Regents of the University of California. All rights reserved.
6: .\"
7: .\" This code is derived from software contributed to Berkeley by
8: .\" the Institute of Electrical and Electronics Engineers, Inc.
9: .\"
10: .\" Redistribution and use in source and binary forms, with or without
11: .\" modification, are permitted provided that the following conditions
12: .\" are met:
13: .\" 1. Redistributions of source code must retain the above copyright
14: .\" notice, this list of conditions and the following disclaimer.
15: .\" 2. Redistributions in binary form must reproduce the above copyright
16: .\" notice, this list of conditions and the following disclaimer in the
17: .\" documentation and/or other materials provided with the distribution.
18: .\" 3. All advertising materials mentioning features or use of this software
19: .\" must display the following acknowledgement:
20: .\" This product includes software developed by the University of
21: .\" California, Berkeley and its contributors.
22: .\" 4. Neither the name of the University nor the names of its contributors
23: .\" may be used to endorse or promote products derived from this software
24: .\" without specific prior written permission.
25: .\"
26: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: .\" SUCH DAMAGE.
37: .\"
38: .\" @(#)tail.1 8.1 (Berkeley) 6/6/93
39: .\"
40: .Dd June 6, 1993
41: .Dt TAIL 1
1.7 aaron 42: .Os
1.1 deraadt 43: .Sh NAME
44: .Nm tail
45: .Nd display the last part of a file
46: .Sh SYNOPSIS
1.6 aaron 47: .Nm tail
1.1 deraadt 48: .Op Fl f Li | Fl r
49: .Oo
50: .Fl b Ar number |
51: .Fl c Ar number |
1.10 ! aaron 52: .Fl n Ar number |
! 53: .Fl Ns Ar number
1.1 deraadt 54: .Oc
55: .Op Ar file ...
56: .Sh DESCRIPTION
57: The
1.3 millert 58: .Nm
1.1 deraadt 59: utility displays the contents of
60: .Ar file
61: or, by default, its standard input, to the standard output.
62: .Pp
1.10 ! aaron 63: The display begins at a byte, line, or 512-byte block location in the
1.1 deraadt 64: input.
1.9 aaron 65: Numbers having a leading plus
66: .Pq Ql +
67: sign are relative to the beginning of the input, for example,
68: .Ic -c +2
1.1 deraadt 69: starts the display at the second
70: byte of the input.
1.9 aaron 71: Numbers having a leading minus
72: .Pq Ql -
73: sign or no explicit sign are
1.1 deraadt 74: relative to the end of the input, for example,
1.9 aaron 75: .Ic -n 2
1.1 deraadt 76: displays the last two lines of the input.
77: The default starting location is
1.9 aaron 78: .Ic -n 10 ,
1.1 deraadt 79: or the last 10 lines of the input.
80: .Pp
81: The options are as follows:
82: .Bl -tag -width Ds
83: .It Fl b Ar number
84: The location is
85: .Ar number
86: 512-byte blocks.
87: .It Fl c Ar number
88: The location is
89: .Ar number
90: bytes.
1.10 ! aaron 91: .It Xo Fl n Ar number No |\
! 92: .Fl Ns Ar number
! 93: .Xc
! 94: The location is
! 95: .Ar number
! 96: lines.
1.1 deraadt 97: .It Fl f
1.10 ! aaron 98: Do not stop when end-of-file is reached, but rather to wait for additional
1.9 aaron 99: data to be appended to the input.
100: If the file is replaced (i.e., the inode number changes),
1.3 millert 101: .Nm
1.9 aaron 102: will reopen the file and continue.
103: If the file is truncated,
1.3 millert 104: .Nm
1.10 ! aaron 105: will reset its position to the beginning.
1.9 aaron 106: This makes
1.3 millert 107: .Nm
108: more useful for watching log files that may get rotated.
1.1 deraadt 109: The
110: .Fl f
111: option is ignored if the standard input is a pipe, but not if it is a FIFO.
112: .It Fl r
113: The
114: .Fl r
115: option causes the input to be displayed in reverse order, by line.
116: Additionally, this option changes the meaning of the
117: .Fl b ,
1.10 ! aaron 118: .Fl c ,
1.1 deraadt 119: and
120: .Fl n
121: options.
122: When the
123: .Fl r
124: option is specified, these options specify the number of bytes, lines
1.10 ! aaron 125: or 512-byte blocks to display, instead of the bytes, lines, or blocks
1.1 deraadt 126: from the beginning or end of the input from which to begin the display.
127: The default for the
128: .Fl r
129: option is to display all of the input.
130: .El
131: .Pp
132: If more than a single file is specified, each file is preceded by a
133: header consisting of the string
134: .Dq ==> XXX <==
135: where
136: .Dq XXX
137: is the name of the file.
138: .Pp
139: The
1.3 millert 140: .Nm
1.5 aaron 141: utility exits 0 on success or >0 if an error occurred.
1.10 ! aaron 142: .Sh EXAMPLES
! 143: To display the last 500 lines of the file
! 144: .Ar foo :
! 145: .Pp
! 146: .Dl $ tail -500 foo
! 147: .Pp
! 148: Keep
! 149: .Pa /var/log/messages
! 150: open, displaying to the standard output anything appended to the file:
! 151: .Pp
! 152: .Dl $ tail -f /var/log/messages
1.1 deraadt 153: .Sh SEE ALSO
154: .Xr cat 1 ,
155: .Xr head 1 ,
156: .Xr sed 1
157: .Sh STANDARDS
158: The
1.3 millert 159: .Nm
1.7 aaron 160: utility is expected to be a superset of the
161: .St -p1003.2-92
1.1 deraadt 162: specification.
163: In particular, the
164: .Fl b
165: and
166: .Fl r
167: options are extensions to that standard.
168: .Pp
169: The historic command line syntax of
1.3 millert 170: .Nm
1.1 deraadt 171: is supported by this implementation.
172: The only difference between this implementation and historic versions
173: of
174: .Nm tail ,
175: once the command line syntax translation has been done, is that the
176: .Fl b ,
177: .Fl c
178: and
179: .Fl n
180: options modify the
181: .Fl r
1.9 aaron 182: option, i.e.,
183: .Ic -r -c 4
184: displays the last 4 characters of the last line
185: of the input, while the historic tail (using the historic syntax
186: .Ic -4cr )
1.1 deraadt 187: would ignore the
188: .Fl c
189: option and display the last 4 lines of the input.
190: .Sh HISTORY
191: A
1.3 millert 192: .Nm
1.1 deraadt 193: command appeared in
194: .At v7 .