taildisplay last lines of a file |
Command |
tail
[-f
]
[-b
|-c
|-k
|-l
|-m
|-n
[±
]num] [file]
tail
+
[num][[b
|c
|k
|l
|m
|n
[f
]
[file]
tail
-
[num][[b
|c
|k
|l
|m
|n
[f
]
[file]
tail
without options displays the last 10 lines of
file. This is useful for seeing the most recent entries in log files
or any file where new information is appended.
tail
options except -f
are mutually
exclusive. You can only specify one of them.
-b
[±
]num±
[num]b
begins displaying the file at a location determined by num. If
num is preceded by a minus sign (-
)or no sign at all,
tail
displays the last num blocks of the file.
If num is preceded by a plus sign (+
),
tail
displays the file beginning with the numth
block. A block is 512 bytes. As a result, -b
num
is equivalent to -c
num x 512.
If num is not specified, tail
behaves as if
num was 10.
-c
[±
]num±
[num]c
is similar to the b
option, but num is in
bytes rather than blocks.
-f
f
monitors a file as it grows. Every two seconds, tail
wakes up and displays any new data at the end of the file. This flag is
ignored if reading from the standard input and standard input is a
pipe.
-k
[±
]num±
[num]k
is similar to the b
option, but num is in
kilobytes (1024 bytes) rather than blocks. Thus, -k
num is equivalent to -c
num x 1024.
-l
[±
]num±
[num]l
is similar to the b
option, but num is in
lines rather than blocks.
-m
[±
]num±
[num]m
is similar to the b
option, but num is in
megabytes (1024 x 1024 bytes) rather than blocks. Thus,
-m
num is equivalent to -c
num x 1024 x 1024.
-n
[±
]num±
[num]n
is similar to the b
option, but num is in
lines rather than blocks.
-
numdisplays the last num lines of the file.
+
numdisplays the file beginning with its numth line.
These three commands all display a file beginning with its 10th byte:tail -c10 filename tail -c -10 filename tail -10c filename tail -c filename
tail -c +10 filename tail +10c filename tail +c filename
0
Successful completion.
1
Failure due to any of the following:
2
Failure due to an unknown command line option.
In an option of the form -n
num or
-
num, the num was not a valid number.
-f
was used to follow a file as it grows.
tail
closed the file associated with the given file
descriptor num then tried to open it two seconds later. At this
point, tail
found it could not re-open the file for
reading and, therefore, could not follow the file any longer.
b
, k
,
l
, or m
as either options or suffixes.