xref: /openbsd/usr.bin/tail/tail.1 (revision ebe9c2f7)
1.\"	$OpenBSD: tail.1,v 1.14 2006/12/28 10:09:19 jmc Exp $
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. Neither the name of the University nor the names of its contributors
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
38.Os
39.Sh NAME
40.Nm tail
41.Nd display the last part of a file
42.Sh SYNOPSIS
43.Nm tail
44.Op Fl f | r
45.Oo
46.Fl b Ar number |
47.Fl c Ar number |
48.Fl n Ar number |
49.Fl Ns Ar number
50.Oc
51.Op Ar
52.Sh DESCRIPTION
53The
54.Nm
55utility displays the contents of
56.Ar file
57or, by default, its standard input, to the standard output.
58.Pp
59The display begins at a byte, line, or 512-byte block location in the
60input.
61Numbers having a leading plus
62.Pq Ql +
63sign are relative to the beginning of the input, for example,
64.Ic -c +2
65starts the display at the second
66byte of the input.
67Numbers having a leading minus
68.Pq Ql -
69sign or no explicit sign are
70relative to the end of the input, for example,
71.Ic -n 2
72displays the last two lines of the input.
73The default starting location is
74.Ic -n 10 ,
75or the last 10 lines of the input.
76.Pp
77The options are as follows:
78.Bl -tag -width Ds
79.It Fl b Ar number
80The location is
81.Ar number
82512-byte blocks.
83.It Fl c Ar number
84The location is
85.Ar number
86bytes.
87.It Fl f
88Do not stop when end-of-file is reached; instead, wait for additional
89data to be appended to the input.
90If the file is replaced (i.e., the inode number changes),
91.Nm
92will reopen the file and continue.
93If the file is truncated,
94.Nm
95will reset its position to the beginning.
96This makes
97.Nm
98more useful for watching log files that may get rotated.
99The
100.Fl f
101option is ignored if the standard input is a pipe, but not if it is a FIFO.
102.It Fl n Ar number \*(Ba Fl Ns Ar number
103The location is
104.Ar number
105lines.
106.It Fl r
107The
108.Fl r
109option causes the input to be displayed in reverse order, by line.
110Additionally, this option changes the meaning of the
111.Fl b ,
112.Fl c ,
113and
114.Fl n
115options.
116When the
117.Fl r
118option is specified, these options specify the number of bytes, lines
119or 512-byte blocks to display, instead of the bytes, lines, or blocks
120from the beginning or end of the input from which to begin the display.
121The default for the
122.Fl r
123option is to display all of the input.
124.El
125.Pp
126If more than a single file is specified, each file is preceded by a
127header consisting of the string
128.Dq ==> XXX <==
129where
130.Dq XXX
131is the name of the file.
132.Pp
133.Ex -std tail
134.Sh EXAMPLES
135To display the last 500 lines of the file
136.Ar foo :
137.Pp
138.Dl $ tail -500 foo
139.Pp
140Keep
141.Pa /var/log/messages
142open, displaying to the standard output anything appended to the file:
143.Pp
144.Dl $ tail -f /var/log/messages
145.Sh SEE ALSO
146.Xr cat 1 ,
147.Xr head 1 ,
148.Xr sed 1
149.Sh STANDARDS
150The
151.Nm
152utility is expected to be a superset of the
153.St -p1003.2-92
154specification.
155In particular, the
156.Fl b
157and
158.Fl r
159options are extensions to that standard.
160.Pp
161The historic command line syntax of
162.Nm
163is supported by this implementation.
164The only difference between this implementation and historic versions
165of
166.Nm tail ,
167once the command line syntax translation has been done, is that the
168.Fl b ,
169.Fl c
170and
171.Fl n
172options modify the
173.Fl r
174option, i.e.,
175.Ic -r -c 4
176displays the last 4 characters of the last line
177of the input, while the historic tail (using the historic syntax
178.Ic -4cr )
179would ignore the
180.Fl c
181option and display the last 4 lines of the input.
182.Sh HISTORY
183A
184.Nm
185command appeared in
186.At v7 .
187