xref: /freebsd/usr.bin/tail/tail.1 (revision 9f20787fe89e2a912a9e5dd2d3da56087722e8c2)
19b50d902SRodney W. Grimes.\" Copyright (c) 1980, 1990, 1991, 1993
29b50d902SRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
39b50d902SRodney W. Grimes.\"
49b50d902SRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
59b50d902SRodney W. Grimes.\" the Institute of Electrical and Electronics Engineers, Inc.
69b50d902SRodney W. Grimes.\"
79b50d902SRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
89b50d902SRodney W. Grimes.\" modification, are permitted provided that the following conditions
99b50d902SRodney W. Grimes.\" are met:
109b50d902SRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
119b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
129b50d902SRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
139b50d902SRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
149b50d902SRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh.\" 3. Neither the name of the University nor the names of its contributors
169b50d902SRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
179b50d902SRodney W. Grimes.\"    without specific prior written permission.
189b50d902SRodney W. Grimes.\"
199b50d902SRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
209b50d902SRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
219b50d902SRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
229b50d902SRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
239b50d902SRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
249b50d902SRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
259b50d902SRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
269b50d902SRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
279b50d902SRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
289b50d902SRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
299b50d902SRodney W. Grimes.\" SUCH DAMAGE.
309b50d902SRodney W. Grimes.\"
3151c27021SMateusz Piotrowski.Dd November 28, 2023
329b50d902SRodney W. Grimes.Dt TAIL 1
3362500372SRuslan Ermilov.Os
349b50d902SRodney W. Grimes.Sh NAME
359b50d902SRodney W. Grimes.Nm tail
369b50d902SRodney W. Grimes.Nd display the last part of a file
379b50d902SRodney W. Grimes.Sh SYNOPSIS
38ea7cc495SPhilippe Charnier.Nm
3961125887SRuslan Ermilov.Op Fl F | f | r
40643ac419SXin LI.Op Fl qv
41aa1d7ce7SFlorent Thoumie.Oo
4261125887SRuslan Ermilov.Fl b Ar number | Fl c Ar number | Fl n Ar number
439b50d902SRodney W. Grimes.Oc
44ea7cc495SPhilippe Charnier.Op Ar
459b50d902SRodney W. Grimes.Sh DESCRIPTION
469b50d902SRodney W. GrimesThe
47ea7cc495SPhilippe Charnier.Nm
489b50d902SRodney W. Grimesutility displays the contents of
499b50d902SRodney W. Grimes.Ar file
509b50d902SRodney W. Grimesor, by default, its standard input, to the standard output.
519b50d902SRodney W. Grimes.Pp
529b50d902SRodney W. GrimesThe display begins at a byte, line or 512-byte block location in the
539b50d902SRodney W. Grimesinput.
5461125887SRuslan ErmilovNumbers having a leading plus
5561125887SRuslan Ermilov.Pq Ql +
5661125887SRuslan Ermilovsign are relative to the beginning
579b50d902SRodney W. Grimesof the input, for example,
5861125887SRuslan Ermilov.Dq Li "-c +2"
599b50d902SRodney W. Grimesstarts the display at the second
609b50d902SRodney W. Grimesbyte of the input.
6161125887SRuslan ErmilovNumbers having a leading minus
6261125887SRuslan Ermilov.Pq Ql -
6361125887SRuslan Ermilovsign or no explicit sign are
649b50d902SRodney W. Grimesrelative to the end of the input, for example,
6561125887SRuslan Ermilov.Dq Li "-n 2"
669b50d902SRodney W. Grimesdisplays the last two lines of the input.
679b50d902SRodney W. GrimesThe default starting location is
6861125887SRuslan Ermilov.Dq Li "-n 10" ,
699b50d902SRodney W. Grimesor the last 10 lines of the input.
709b50d902SRodney W. Grimes.Pp
719b50d902SRodney W. GrimesThe options are as follows:
7261125887SRuslan Ermilov.Bl -tag -width indent
7353128fb4SKyle Evans.It Fl b Ar number , Fl -blocks Ns = Ns Ar number
749b50d902SRodney W. GrimesThe location is
759b50d902SRodney W. Grimes.Ar number
769b50d902SRodney W. Grimes512-byte blocks.
7753128fb4SKyle Evans.It Fl c Ar number , Fl -bytes Ns = Ns Ar number
789b50d902SRodney W. GrimesThe location is
799b50d902SRodney W. Grimes.Ar number
809b50d902SRodney W. Grimesbytes.
819b50d902SRodney W. Grimes.It Fl f
829b50d902SRodney W. GrimesThe
839b50d902SRodney W. Grimes.Fl f
849b50d902SRodney W. Grimesoption causes
85ea7cc495SPhilippe Charnier.Nm
869b50d902SRodney W. Grimesto not stop when end of file is reached, but rather to wait for additional
879b50d902SRodney W. Grimesdata to be appended to the input.
889b50d902SRodney W. GrimesThe
899b50d902SRodney W. Grimes.Fl f
909b50d902SRodney W. Grimesoption is ignored if the standard input is a pipe, but not if it is a FIFO.
91eb1c9439SPeter Wemm.It Fl F
92eb1c9439SPeter WemmThe
93eb1c9439SPeter Wemm.Fl F
94eb1c9439SPeter Wemmoption implies the
95eb1c9439SPeter Wemm.Fl f
96eb1c9439SPeter Wemmoption, but
97eb1c9439SPeter Wemm.Nm
98eb1c9439SPeter Wemmwill also check to see if the file being followed has been renamed or rotated.
99eb1c9439SPeter WemmThe file is closed and reopened when
100eb1c9439SPeter Wemm.Nm
101eb1c9439SPeter Wemmdetects that the filename being read from has a new inode number.
10222da50cfSBrian Somers.Pp
10322da50cfSBrian SomersIf the file being followed does not (yet) exist or if it is removed, tail
10422da50cfSBrian Somerswill keep looking and will display the file from the beginning if and when
10522da50cfSBrian Somersit is created.
10622da50cfSBrian Somers.Pp
107eb1c9439SPeter WemmThe
108eb1c9439SPeter Wemm.Fl F
10922da50cfSBrian Somersoption is the same as the
11022da50cfSBrian Somers.Fl f
11122da50cfSBrian Somersoption if reading from standard input rather than a file.
11253128fb4SKyle Evans.It Fl n Ar number , Fl -lines Ns = Ns Ar number
1139b50d902SRodney W. GrimesThe location is
1149b50d902SRodney W. Grimes.Ar number
1159b50d902SRodney W. Grimeslines.
116643ac419SXin LI.It Fl q , Fl -quiet , Fl -silent
117aa1d7ce7SFlorent ThoumieSuppresses printing of headers when multiple files are being examined.
1189b50d902SRodney W. Grimes.It Fl r
1199b50d902SRodney W. GrimesThe
1209b50d902SRodney W. Grimes.Fl r
1219b50d902SRodney W. Grimesoption causes the input to be displayed in reverse order, by line.
1229b50d902SRodney W. GrimesAdditionally, this option changes the meaning of the
12361125887SRuslan Ermilov.Fl b , c
1249b50d902SRodney W. Grimesand
1259b50d902SRodney W. Grimes.Fl n
1269b50d902SRodney W. Grimesoptions.
1279b50d902SRodney W. GrimesWhen the
1289b50d902SRodney W. Grimes.Fl r
1299b50d902SRodney W. Grimesoption is specified, these options specify the number of bytes, lines
1309b50d902SRodney W. Grimesor 512-byte blocks to display, instead of the bytes, lines or blocks
1319b50d902SRodney W. Grimesfrom the beginning or end of the input from which to begin the display.
1329b50d902SRodney W. GrimesThe default for the
1339b50d902SRodney W. Grimes.Fl r
1349b50d902SRodney W. Grimesoption is to display all of the input.
135643ac419SXin LI.It Fl v , Fl -verbose
136643ac419SXin LIPrepend each file with a header.
1379b50d902SRodney W. Grimes.El
1389b50d902SRodney W. Grimes.Pp
139643ac419SXin LIIf more than a single file is specified, or if the
140643ac419SXin LI.Fl v
141643ac419SXin LIoption is used, each file is preceded by a
1429b50d902SRodney W. Grimesheader consisting of the string
14361125887SRuslan Ermilov.Dq Li "==> " Ns Ar XXX Ns Li " <=="
1449b50d902SRodney W. Grimeswhere
14561125887SRuslan Ermilov.Ar XXX
146643ac419SXin LIis the name of the file.
147643ac419SXin LIThe
148aa1d7ce7SFlorent Thoumie.Fl q
149643ac419SXin LIflag disables the printing of the header in all cases.
150643ac419SXin LI.Pp
151643ac419SXin LIAll
152643ac419SXin LI.Ar number
153643ac419SXin LIarguments may also be specified with size suffixes supported by
154643ac419SXin LI.Xr expand_number 3 .
155a866e170SRuslan Ermilov.Sh EXIT STATUS
156d628d776SRuslan Ermilov.Ex -std
157b16958a1SJoel Dahl.Sh EXAMPLES
158*9f20787fSMateusz PiotrowskiDisplay the last 500 lines of the file
159b16958a1SJoel Dahl.Ar foo :
160b16958a1SJoel Dahl.Pp
161b16958a1SJoel Dahl.Dl $ tail -n 500 foo
162b16958a1SJoel Dahl.Pp
163b16958a1SJoel DahlKeep
164b16958a1SJoel Dahl.Pa /var/log/messages
165b16958a1SJoel Dahlopen, displaying to the standard output anything appended to the file:
166b16958a1SJoel Dahl.Pp
167c0f2b64aSMateusz Piotrowski.Dl $ tail -F /var/log/messages
168*9f20787fSMateusz Piotrowski.Pp
169*9f20787fSMateusz PiotrowskiRead
170*9f20787fSMateusz Piotrowski.Pa /var/log/messages
171*9f20787fSMateusz Piotrowskifrom the beginning and then follow the file as usual:
172*9f20787fSMateusz Piotrowski.Pp
173*9f20787fSMateusz Piotrowski.Dl $ tail -F -n +1 /var/log/messages
1749b50d902SRodney W. Grimes.Sh SEE ALSO
1759b50d902SRodney W. Grimes.Xr cat 1 ,
1769b50d902SRodney W. Grimes.Xr head 1 ,
177643ac419SXin LI.Xr sed 1 ,
178643ac419SXin LI.Xr expand_number 3
1799b50d902SRodney W. Grimes.Sh STANDARDS
1809b50d902SRodney W. GrimesThe
181ea7cc495SPhilippe Charnier.Nm
182ea7cc495SPhilippe Charnierutility is expected to be a superset of the
183ea7cc495SPhilippe Charnier.St -p1003.2-92
1849b50d902SRodney W. Grimesspecification.
1859b50d902SRodney W. GrimesIn particular, the
186eb1c9439SPeter Wemm.Fl F ,
1879b50d902SRodney W. Grimes.Fl b
1889b50d902SRodney W. Grimesand
1899b50d902SRodney W. Grimes.Fl r
1909b50d902SRodney W. Grimesoptions are extensions to that standard.
1919b50d902SRodney W. Grimes.Pp
1929b50d902SRodney W. GrimesThe historic command line syntax of
193ea7cc495SPhilippe Charnier.Nm
1949b50d902SRodney W. Grimesis supported by this implementation.
1959b50d902SRodney W. GrimesThe only difference between this implementation and historic versions
1969b50d902SRodney W. Grimesof
1978fe908efSRuslan Ermilov.Nm ,
1989b50d902SRodney W. Grimesonce the command line syntax translation has been done, is that the
1999b50d902SRodney W. Grimes.Fl b ,
2009b50d902SRodney W. Grimes.Fl c
2019b50d902SRodney W. Grimesand
2029b50d902SRodney W. Grimes.Fl n
2039b50d902SRodney W. Grimesoptions modify the
2049b50d902SRodney W. Grimes.Fl r
20561125887SRuslan Ermilovoption, i.e.,
20661125887SRuslan Ermilov.Dq Li "-r -c 4"
20761125887SRuslan Ermilovdisplays the last 4 characters of the last line
20861125887SRuslan Ermilovof the input, while the historic tail (using the historic syntax
20961125887SRuslan Ermilov.Dq Li -4cr )
2109b50d902SRodney W. Grimeswould ignore the
2119b50d902SRodney W. Grimes.Fl c
2129b50d902SRodney W. Grimesoption and display the last 4 lines of the input.
2139b50d902SRodney W. Grimes.Sh HISTORY
2149b50d902SRodney W. GrimesA
215ea7cc495SPhilippe Charnier.Nm
2166fc8ba94SJuli Mallettcommand appeared in PWB UNIX.
217