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