1.\" $OpenBSD: tail.1,v 1.21 2015/02/28 21:51:57 bentley 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. Neither the name of the University nor the names of its contributors 19.\" may be used to endorse or promote products derived from this software 20.\" without specific prior written permission. 21.\" 22.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32.\" SUCH DAMAGE. 33.\" 34.\" @(#)tail.1 8.1 (Berkeley) 6/6/93 35.\" 36.Dd $Mdocdate: February 28 2015 $ 37.Dt TAIL 1 38.Os 39.Sh NAME 40.Nm tail 41.Nd display the last part of a file 42.Sh SYNOPSIS 43.Nm tail 44.Op Fl f | r 45.Oo 46.Fl b Ar number | 47.Fl c Ar number | 48.Fl n Ar number | 49.Fl Ns Ar number 50.Oc 51.Op Ar 52.Sh DESCRIPTION 53The 54.Nm 55utility displays the contents of 56.Ar file 57or, by default, its standard input, to the standard output. 58.Pp 59The display begins at a byte, line, or 512-byte block location in the 60input. 61Numbers having a leading plus 62.Pq Ql + 63sign are relative to the beginning of the input, for example, 64.Ic -c +2 65starts the display at the second 66byte of the input. 67Numbers having a leading minus 68.Pq Ql - 69sign or no explicit sign are 70relative to the end of the input, for example, 71.Ic -n 2 72displays the last two lines of the input. 73The default starting location is 74.Ic -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 88Do not stop when end-of-file is reached; instead, wait for additional 89data to be appended to the input. 90If the file is replaced (i.e., the inode number changes), 91.Nm 92will reopen the file and continue. 93If the file is truncated, 94.Nm 95will reset its position to the beginning. 96This makes 97.Nm 98more useful for watching log files that may get rotated. 99The 100.Fl f 101option is ignored if there are no 102.Fa file 103arguments and the standard input is a pipe or a FIFO. 104.It Fl n Ar number | Fl Ns Ar number 105The location is 106.Ar number 107lines. 108.It Fl r 109The 110.Fl r 111option causes the input to be displayed in reverse order, by line. 112Additionally, this option changes the meaning of the 113.Fl b , 114.Fl c , 115and 116.Fl n 117options. 118When the 119.Fl r 120option is specified, these options specify the number of bytes, lines 121or 512-byte blocks to display, instead of the bytes, lines, or blocks 122from the beginning or end of the input from which to begin the display. 123The default for the 124.Fl r 125option is to display all of the input. 126.El 127.Pp 128If more than a single file is specified, each file is preceded by a 129header consisting of the string 130.Dq ==> XXX <== 131where 132.Dq XXX 133is the name of the file. 134.Sh EXIT STATUS 135.Ex -std tail 136.Sh EXAMPLES 137To display the last 500 lines of the file 138.Ar foo : 139.Pp 140.Dl $ tail -500 foo 141.Pp 142Keep 143.Pa /var/log/messages 144open, displaying to the standard output anything appended to the file: 145.Pp 146.Dl $ tail -f /var/log/messages 147.Sh SEE ALSO 148.Xr cat 1 , 149.Xr head 1 , 150.Xr sed 1 151.Sh STANDARDS 152The 153.Nm 154utility is compliant with the 155.St -p1003.1-2008 156specification. 157.Pp 158The flags 159.Op Fl br 160are extensions to that specification. 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 tail , 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., 176.Ic -r -c 4 177displays the last 4 characters of the last line 178of the input, while the historic tail (using the historic syntax 179.Ic -4cr ) 180would ignore the 181.Fl c 182option and display the last 4 lines of the input. 183.Sh HISTORY 184A 185.Nm 186command appeared in 187.At v7 . 188