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