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