xref: /original-bsd/usr.bin/tail/tail.1 (revision c3e32dec)
1.\" Copyright (c) 1980, 1990, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" %sccs.include.redist.roff%
8.\"
9.\"	@(#)tail.1	8.1 (Berkeley) 06/06/93
10.\"
11.Dd
12.Dt TAIL 1
13.Os BSD 4
14.Sh NAME
15.Nm tail
16.Nd display the last part of a file
17.Sh SYNOPSIS
18.Nm tail
19.Op Fl f Li | Fl r
20.Oo
21.Fl b Ar number |
22.Fl c Ar number |
23.Fl n Ar number
24.Oc
25.Op Ar file ...
26.Sh DESCRIPTION
27The
28.Nm tail
29utility displays the contents of
30.Ar file
31or, by default, its standard input, to the standard output.
32.Pp
33The display begins at a byte, line or 512-byte block location in the
34input.
35Numbers having a leading plus (``+'') sign are relative to the beginning
36of the input, for example,
37.Dq -c +2
38starts the display at the second
39byte of the input.
40Numbers having a leading minus (``-'') sign or no explicit sign are
41relative to the end of the input, for example,
42.Dq -n 2
43displays the last two lines of the input.
44The default starting location is
45.Dq -n 10 ,
46or the last 10 lines of the input.
47.Pp
48The options are as follows:
49.Bl -tag -width Ds
50.It Fl b Ar number
51The location is
52.Ar number
53512-byte blocks.
54.It Fl c Ar number
55The location is
56.Ar number
57bytes.
58.It Fl f
59The
60.Fl f
61option causes
62.Nm tail
63to not stop when end of file is reached, but rather to wait for additional
64data to be appended to the input.
65The
66.Fl f
67option is ignored if the standard input is a pipe, but not if it is a FIFO.
68.It Fl n Ar number
69The location is
70.Ar number
71lines.
72.It Fl r
73The
74.Fl r
75option causes the input to be displayed in reverse order, by line.
76Additionally, this option changes the meaning of the
77.Fl b ,
78.Fl c
79and
80.Fl n
81options.
82When the
83.Fl r
84option is specified, these options specify the number of bytes, lines
85or 512-byte blocks to display, instead of the bytes, lines or blocks
86from the beginning or end of the input from which to begin the display.
87The default for the
88.Fl r
89option is to display all of the input.
90.El
91.Pp
92If more than a single file is specified, each file is preceded by a
93header consisting of the string
94.Dq ==> XXX <==
95where
96.Dq XXX
97is the name of the file.
98.Pp
99The
100.Nm tail
101utility exits 0 on success, and >0 if an error occurs.
102.Sh SEE ALSO
103.Xr cat 1 ,
104.Xr head 1 ,
105.Xr sed 1
106.Sh STANDARDS
107The
108.Nm tail
109utility is expected to be a superset of the POSIX 1003.2
110specification.
111In particular, the
112.Fl b
113and
114.Fl r
115options are extensions to that standard.
116.Pp
117The historic command line syntax of
118.Nm tail
119is supported by this implementation.
120The only difference between this implementation and historic versions
121of
122.Nm tail ,
123once the command line syntax translation has been done, is that the
124.Fl b ,
125.Fl c
126and
127.Fl n
128options modify the
129.Fl r
130option, i.e. ``-r -c 4'' displays the last 4 characters of the last line
131of the input, while the historic tail (using the historic syntax ``-4cr'')
132would ignore the
133.Fl c
134option and display the last 4 lines of the input.
135.Sh HISTORY
136A
137.Nm tail
138command appeared in
139.At v7 .
140