1.\" $NetBSD: tail.1,v 1.21 2022/08/28 10:48:17 hgutch 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 October 1, 2017 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.Fl qv 44.Oo 45.Fl f | 46.Fl F | 47.Fl r 48.Oc 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 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 92not to 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 there are no file arguments and the standard 97input is a pipe or a FIFO. 98.It Fl F 99The 100.Fl F 101option is the same as the 102.Fl f 103option, except that every five seconds 104.Nm 105will check to see if the file named on the command line has been 106shortened or moved (it is considered moved if the inode or device 107number changes) and, if so, it will close 108the current file, open the filename given, print out the entire 109contents, and continue to wait for more data to be appended. 110This option is used to follow log files though rotation by 111.Xr newsyslog 8 112or similar programs. 113.It Fl n Ar number 114The location is 115.Ar number 116lines. 117.It Fl q 118Do not prepend a header for each file, even if multiple files 119are specified. 120.It Fl r 121The 122.Fl r 123option causes the input to be displayed in reverse order, by line. 124Additionally, this option changes the meaning of the 125.Fl b , 126.Fl c 127and 128.Fl n 129options. 130When the 131.Fl r 132option is specified, these options specify the number of bytes, lines 133or 512-byte blocks to display, instead of the bytes, lines or blocks 134from the beginning or end of the input from which to begin the display. 135The default for the 136.Fl r 137option is to display all of the input. 138.It Fl v 139Prepend each file with a header. 140.El 141.Pp 142If more than a single file is specified, or the 143.Fl v 144option is used, each file is preceded by a 145header consisting of the string 146.Dq ==> XXX <== 147where 148.Dq XXX 149is the name of the file. 150The 151.Fl q 152flag disables the printing of the header in all cases. 153.Sh EXIT STATUS 154.Ex -std tail 155.Sh SEE ALSO 156.Xr cat 1 , 157.Xr head 1 , 158.Xr sed 1 159.Sh STANDARDS 160The 161.Nm 162utility is expected to be a superset of the 163.St -p1003.2-92 164specification. 165In particular, the 166.Fl b , 167.Fl r 168and 169.Fl F 170options are extensions to that standard. 171.Pp 172The historic command line syntax of 173.Nm 174is supported by this implementation. 175The only difference between this implementation and historic versions 176of 177.Nm , 178once the command line syntax translation has been done, is that the 179.Fl b , 180.Fl c 181and 182.Fl n 183options modify the 184.Fl r 185option, i.e., ``-r -c 4'' displays the last 4 characters of the last line 186of the input, while the historic tail (using the historic syntax ``-4cr'') 187would ignore the 188.Fl c 189option and display the last 4 lines of the input. 190.Sh HISTORY 191A 192.Nm 193command appeared in 194.At v7 . 195.Sh BUGS 196When using the 197.Fl F 198option, 199.Nm 200will not detect a file truncation if, between the truncation 201and the next check of the file size, data written to the file make 202it larger than the last known file size. 203