xref: /openbsd/usr.bin/tail/tail.1 (revision 07ea8d15)
1.\"	$OpenBSD: tail.1,v 1.2 1996/06/26 05:40:17 deraadt 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. 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
42.Os BSD 4
43.Sh NAME
44.Nm tail
45.Nd display the last part of a file
46.Sh SYNOPSIS
47.Nm tail
48.Op Fl f Li | Fl r
49.Oo
50.Fl b Ar number |
51.Fl c Ar number |
52.Fl n Ar number
53.Oc
54.Op Ar file ...
55.Sh DESCRIPTION
56The
57.Nm tail
58utility displays the contents of
59.Ar file
60or, by default, its standard input, to the standard output.
61.Pp
62The display begins at a byte, line or 512-byte block location in the
63input.
64Numbers having a leading plus (``+'') sign are relative to the beginning
65of the input, for example,
66.Dq -c +2
67starts the display at the second
68byte of the input.
69Numbers having a leading minus (``-'') sign or no explicit sign are
70relative to the end of the input, for example,
71.Dq -n 2
72displays the last two lines of the input.
73The default starting location is
74.Dq -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
88The
89.Fl f
90option causes
91.Nm tail
92to not stop when end of file is reached, but rather to wait for additional
93data to be appended to the input.
94The
95.Fl f
96option is ignored if the standard input is a pipe, but not if it is a FIFO.
97.It Fl n Ar number
98The location is
99.Ar number
100lines.
101.It Fl r
102The
103.Fl r
104option causes the input to be displayed in reverse order, by line.
105Additionally, this option changes the meaning of the
106.Fl b ,
107.Fl c
108and
109.Fl n
110options.
111When the
112.Fl r
113option is specified, these options specify the number of bytes, lines
114or 512-byte blocks to display, instead of the bytes, lines or blocks
115from the beginning or end of the input from which to begin the display.
116The default for the
117.Fl r
118option is to display all of the input.
119.El
120.Pp
121If more than a single file is specified, each file is preceded by a
122header consisting of the string
123.Dq ==> XXX <==
124where
125.Dq XXX
126is the name of the file.
127.Pp
128The
129.Nm tail
130utility exits 0 on success, and >0 if an error occurs.
131.Sh SEE ALSO
132.Xr cat 1 ,
133.Xr head 1 ,
134.Xr sed 1
135.Sh STANDARDS
136The
137.Nm tail
138utility is expected to be a superset of the
139.St -p1003.2-92
140specification.
141In particular, the
142.Fl b
143and
144.Fl r
145options are extensions to that standard.
146.Pp
147The historic command line syntax of
148.Nm tail
149is supported by this implementation.
150The only difference between this implementation and historic versions
151of
152.Nm tail ,
153once the command line syntax translation has been done, is that the
154.Fl b ,
155.Fl c
156and
157.Fl n
158options modify the
159.Fl r
160option, i.e. ``-r -c 4'' displays the last 4 characters of the last line
161of the input, while the historic tail (using the historic syntax ``-4cr'')
162would ignore the
163.Fl c
164option and display the last 4 lines of the input.
165.Sh HISTORY
166A
167.Nm tail
168command appeared in
169.At v7 .
170