1.\" $OpenBSD: tail.1,v 1.9 2000/03/11 21:40:04 aaron 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. All advertising materials mentioning features or use of this software 19.\" must display the following acknowledgement: 20.\" This product includes software developed by the University of 21.\" California, Berkeley and its contributors. 22.\" 4. Neither the name of the University nor the names of its contributors 23.\" may be used to endorse or promote products derived from this software 24.\" without specific prior written permission. 25.\" 26.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36.\" SUCH DAMAGE. 37.\" 38.\" @(#)tail.1 8.1 (Berkeley) 6/6/93 39.\" 40.Dd June 6, 1993 41.Dt TAIL 1 42.Os 43.Sh NAME 44.Nm tail 45.Nd display the last part of a file 46.Sh SYNOPSIS 47.Nm tail 48.Op Fl f Li | Fl r 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 65.Pq Ql + 66sign are relative to the beginning of the input, for example, 67.Ic -c +2 68starts the display at the second 69byte of the input. 70Numbers having a leading minus 71.Pq Ql - 72sign or no explicit sign are 73relative to the end of the input, for example, 74.Ic -n 2 75displays the last two lines of the input. 76The default starting location is 77.Ic -n 10 , 78or the last 10 lines of the input. 79.Pp 80The options are as follows: 81.Bl -tag -width Ds 82.It Fl b Ar number 83The location is 84.Ar number 85512-byte blocks. 86.It Fl c Ar number 87The location is 88.Ar number 89bytes. 90.It Fl f 91The 92.Fl f 93option causes 94.Nm 95to not stop when end-of-file is reached, but rather to wait for additional 96data to be appended to the input. 97If the file is replaced (i.e., the inode number changes), 98.Nm 99will reopen the file and continue. 100If the file is truncated, 101.Nm 102will reset its position back to the beginning. 103This makes 104.Nm 105more useful for watching log files that may get rotated. 106The 107.Fl f 108option is ignored if the standard input is a pipe, but not if it is a FIFO. 109.It Fl n Ar number 110The location is 111.Ar number 112lines. 113.It Fl r 114The 115.Fl r 116option causes the input to be displayed in reverse order, by line. 117Additionally, this option changes the meaning of the 118.Fl b , 119.Fl c 120and 121.Fl n 122options. 123When the 124.Fl r 125option is specified, these options specify the number of bytes, lines 126or 512-byte blocks to display, instead of the bytes, lines or blocks 127from the beginning or end of the input from which to begin the display. 128The default for the 129.Fl r 130option is to display all of the input. 131.El 132.Pp 133If more than a single file is specified, each file is preceded by a 134header consisting of the string 135.Dq ==> XXX <== 136where 137.Dq XXX 138is the name of the file. 139.Pp 140The 141.Nm 142utility exits 0 on success or >0 if an error occurred. 143.Sh SEE ALSO 144.Xr cat 1 , 145.Xr head 1 , 146.Xr sed 1 147.Sh STANDARDS 148The 149.Nm 150utility is expected to be a superset of the 151.St -p1003.2-92 152specification. 153In particular, the 154.Fl b 155and 156.Fl r 157options are extensions to that standard. 158.Pp 159The historic command line syntax of 160.Nm 161is supported by this implementation. 162The only difference between this implementation and historic versions 163of 164.Nm tail , 165once the command line syntax translation has been done, is that the 166.Fl b , 167.Fl c 168and 169.Fl n 170options modify the 171.Fl r 172option, i.e., 173.Ic -r -c 4 174displays the last 4 characters of the last line 175of the input, while the historic tail (using the historic syntax 176.Ic -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