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