This post was originally published on go2linux.org on May 5, 2007. The domain is no longer mine, but I am the original author. I am republishing it here on garron.me with corrections and improvements.
This command is related to head, but opposite — instead of displaying the beginning of a file, it displays the end.
It also has a great feature: if you use it with the -f option, it will keep following the file and show new lines as they get appended. This is extremely useful when you are debugging and watching files in the /var/log directory.
Usage
tail [options] [file-list]
Options
-c=[+]n[u]
tail counts bytes instead of lines. It displays the last n bytes specified in the n option. The [u] option is optional and lets you indicate the unit:
b= bytesk= kilobytesm= megabytes
If you add the + sign before n, tail counts from the top instead of the end, displaying from line +n onwards.
-f
After showing the last line of the file, tail stays open and waits for new lines, displaying them as soon as they are written. You can specify more than one file in [file-list], and tail will tell you which file each new line comes from.
-n [+]n[u]
This is the default option. It works like -c but counts lines instead of bytes. You can also specify the [u] parameter for units, and use the + sign to count from the top of the file rather than from the end.
The man page
TAIL(1) TAIL(1)
NAME
tail - output the last part of files
SYNOPSIS
tail [OPTION]... [FILE]...
DESCRIPTION
Print the last 10 lines of each FILE to standard output. With more than
one FILE, precede each with a header giving the file name. With no FILE,
or when FILE is -, read standard input.
-c, --bytes=N
output the last N bytes; alternatively, use +N to output bytes
starting with the Nth of each file
-f, --follow[={name|descriptor}]
output appended data as the file grows; -f, --follow, and
--follow=descriptor are equivalent
-n, --lines=N
output the last N lines, instead of the last 10; or use +N to
output lines starting with the Nth
--pid=PID
with -f, terminate after process ID, PID dies
-q, --quiet, --silent
never output headers giving file names
-s, --sleep-interval=S
with -f, sleep for approximately S seconds (default 1.0) between
iterations
-v, --verbose
always output headers giving file names