Annotation of src/usr.bin/tail/tail.1, Revision 1.12
1.12 ! jmc 1: .\" $OpenBSD: tail.1,v 1.11 2003/06/03 02:56:17 millert 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.1 deraadt 44: .Op Fl f Li | Fl r
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
51: .Op Ar file ...
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.
1.10 aaron 87: .It Xo Fl n Ar number No |\
88: .Fl Ns Ar number
89: .Xc
90: The location is
91: .Ar number
92: lines.
1.1 deraadt 93: .It Fl f
1.12 ! jmc 94: Do not stop when end-of-file is reached; instead, wait for additional
1.9 aaron 95: data to be appended to the input.
96: If the file is replaced (i.e., the inode number changes),
1.3 millert 97: .Nm
1.9 aaron 98: will reopen the file and continue.
99: If the file is truncated,
1.3 millert 100: .Nm
1.10 aaron 101: will reset its position to the beginning.
1.9 aaron 102: This makes
1.3 millert 103: .Nm
104: more useful for watching log files that may get rotated.
1.1 deraadt 105: The
106: .Fl f
107: option is ignored if the standard input is a pipe, but not if it is a FIFO.
108: .It Fl r
109: The
110: .Fl r
111: option causes the input to be displayed in reverse order, by line.
112: Additionally, this option changes the meaning of the
113: .Fl b ,
1.10 aaron 114: .Fl c ,
1.1 deraadt 115: and
116: .Fl n
117: options.
118: When the
119: .Fl r
120: option is specified, these options specify the number of bytes, lines
1.10 aaron 121: or 512-byte blocks to display, instead of the bytes, lines, or blocks
1.1 deraadt 122: from the beginning or end of the input from which to begin the display.
123: The default for the
124: .Fl r
125: option is to display all of the input.
126: .El
127: .Pp
128: If more than a single file is specified, each file is preceded by a
129: header consisting of the string
130: .Dq ==> XXX <==
131: where
132: .Dq XXX
133: is the name of the file.
134: .Pp
135: The
1.3 millert 136: .Nm
1.5 aaron 137: utility exits 0 on success or >0 if an error occurred.
1.10 aaron 138: .Sh EXAMPLES
139: To display the last 500 lines of the file
140: .Ar foo :
141: .Pp
142: .Dl $ tail -500 foo
143: .Pp
144: Keep
145: .Pa /var/log/messages
146: open, displaying to the standard output anything appended to the file:
147: .Pp
148: .Dl $ tail -f /var/log/messages
1.1 deraadt 149: .Sh SEE ALSO
150: .Xr cat 1 ,
151: .Xr head 1 ,
152: .Xr sed 1
153: .Sh STANDARDS
154: The
1.3 millert 155: .Nm
1.7 aaron 156: utility is expected to be a superset of the
157: .St -p1003.2-92
1.1 deraadt 158: specification.
159: In particular, the
160: .Fl b
161: and
162: .Fl r
163: options are extensions to that standard.
164: .Pp
165: The historic command line syntax of
1.3 millert 166: .Nm
1.1 deraadt 167: is supported by this implementation.
168: The only difference between this implementation and historic versions
169: of
170: .Nm tail ,
171: once the command line syntax translation has been done, is that the
172: .Fl b ,
173: .Fl c
174: and
175: .Fl n
176: options modify the
177: .Fl r
1.9 aaron 178: option, i.e.,
179: .Ic -r -c 4
180: displays the last 4 characters of the last line
181: of the input, while the historic tail (using the historic syntax
182: .Ic -4cr )
1.1 deraadt 183: would ignore the
184: .Fl c
185: option and display the last 4 lines of the input.
186: .Sh HISTORY
187: A
1.3 millert 188: .Nm
1.1 deraadt 189: command appeared in
190: .At v7 .