1.\" $MirOS: src/usr.bin/tail/tail.1,v 1.3 2012/05/20 15:13:18 tg Exp $ 2.\" $OpenBSD: tail.1,v 1.11 2003/06/03 02:56:17 millert Exp $ 3.\" $NetBSD: tail.1,v 1.4 1994/11/23 07:42:13 jtc Exp $ 4.\" 5.\" Copyright (c) 1980, 1990, 1991, 1993 6.\" The Regents of the University of California. All rights reserved. 7.\" 8.\" This code is derived from software contributed to Berkeley by 9.\" the Institute of Electrical and Electronics Engineers, Inc. 10.\" 11.\" Redistribution and use in source and binary forms, with or without 12.\" modification, are permitted provided that the following conditions 13.\" are met: 14.\" 1. Redistributions of source code must retain the above copyright 15.\" notice, this list of conditions and the following disclaimer. 16.\" 2. Redistributions in binary form must reproduce the above copyright 17.\" notice, this list of conditions and the following disclaimer in the 18.\" documentation and/or other materials provided with the distribution. 19.\" 3. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.\" @(#)tail.1 8.1 (Berkeley) 6/6/93 36.\" 37.Dd $Mdocdate: May 20 2012 $ 38.Dt TAIL 1 39.Os 40.Sh NAME 41.Nm tail 42.Nd display the last part of a file 43.Sh SYNOPSIS 44.Nm tail 45.Op Fl Ff Li | Fl r 46.Oo 47.Fl b Ar number | 48.Fl c Ar number | 49.Fl n Ar number | 50.Fl Ns Ar number 51.Oc 52.Op Ar file ... 53.Sh DESCRIPTION 54The 55.Nm 56utility displays the contents of 57.Ar file 58or, by default, its standard input, to the standard output. 59.Pp 60The display begins at a byte, line, or 512-byte block location in the 61input. 62Numbers having a leading plus 63.Pq Ql + 64sign are relative to the beginning of the input, for example, 65.Ic -c +2 66starts the display at the second 67byte of the input. 68Numbers having a leading minus 69.Pq Ql - 70sign or no explicit sign are 71relative to the end of the input, for example, 72.Ic -n 2 73displays the last two lines of the input. 74The default starting location is 75.Ic -n 10 , 76or the last 10 lines of the input. 77.Pp 78The options are as follows: 79.Bl -tag -width Ds 80.It Fl b Ar number 81The location is 82.Ar number 83512-byte blocks. 84.It Fl c Ar number 85The location is 86.Ar number 87bytes. 88.It Xo Fl n Ar number No |\ 89.Fl Ns Ar number 90.Xc 91The location is 92.Ar number 93lines. 94.It Fl F 95Does the same as 96.Fl f , 97for GNU compatibility, where their 98.Nm 99.Fl f 100does not follow replaced files automatically. 101As a 102.Mx 103extension, sets output to line-buffered even if it's not a terminal. 104.It Fl f 105Do not stop when end-of-file is reached, but rather to wait for additional 106data to be appended to the input. 107If the file is replaced (i.e., the inode number changes), 108.Nm 109will reopen the file and continue. 110If the file is truncated, 111.Nm 112will reset its position to the beginning. 113This makes 114.Nm 115more useful for watching log files that may get rotated. 116The 117.Fl f 118option is ignored if the standard input is a pipe, but not if it is a FIFO. 119.It Fl r 120The 121.Fl r 122option causes the input to be displayed in reverse order, by line. 123Additionally, this option changes the meaning of the 124.Fl b , 125.Fl c , 126and 127.Fl n 128options. 129When the 130.Fl r 131option is specified, these options specify the number of bytes, lines 132or 512-byte blocks to display, instead of the bytes, lines, or blocks 133from the beginning or end of the input from which to begin the display. 134The default for the 135.Fl r 136option is to display all of the input. 137.El 138.Pp 139If more than a single file is specified, each file is preceded by a 140header consisting of the string 141.Dq ==> XXX <== 142where 143.Dq XXX 144is the name of the file. 145.Pp 146The 147.Nm 148utility exits 0 on success or >0 if an error occurred. 149.Sh EXAMPLES 150To display the last 500 lines of the file 151.Ar foo : 152.Pp 153.Dl $ tail -500 foo 154.Pp 155Keep 156.Pa /var/log/messages 157open, displaying to the standard output anything appended to the file: 158.Pp 159.Dl $ tail -f /var/log/messages 160.Sh SEE ALSO 161.Xr cat 1 , 162.Xr head 1 , 163.Xr sed 1 164.Sh STANDARDS 165The 166.Nm 167utility is expected to be a superset of the 168.St -p1003.2-92 169specification. 170In particular, the 171.Fl b 172and 173.Fl r 174options are extensions to that standard. 175.Pp 176The historic command line syntax of 177.Nm 178is supported by this implementation. 179The only difference between this implementation and historic versions 180of 181.Nm tail , 182once the command line syntax translation has been done, is that the 183.Fl b , 184.Fl c 185and 186.Fl n 187options modify the 188.Fl r 189option, i.e., 190.Ic -r -c 4 191displays the last 4 characters of the last line 192of the input, while the historic tail (using the historic syntax 193.Ic -4cr ) 194would ignore the 195.Fl c 196option and display the last 4 lines of the input. 197.Sh HISTORY 198A 199.Nm 200command appeared in 201.At v7 . 202