Name

tail

Synopsis

tail [options] [file]

Prints the last 10 lines of the named file. Uses either -f or -r, but not both.

Options

-f

Don’t quit at the end of file; “follow” file as it grows. End with an INTR (usually ^C).

-F

Behaves the same as the -f option with the exception that it checks every five seconds to see if the filename has changed. If it has, it closes the file and opens the new file.

-r

Copy lines in reverse order.

-c n

Begin printing at nth byte from the end of file.

-b n

Begin printing at nth block from the end of file.

-n n

Start at nth line from the end of file. -n is the default and doesn’t need to be specified.

[+/-]

To start from the beginning of the file, use + before num. The default is to start from the end of the file; this can also be done by using a - before num.

Examples

Show the last 20 lines containing instances of .Ah:

$ grep '\.Ah' file | tail -20

Continually track the system log:

$ tail -f /var/log/system.log

Show the last 10 characters of variable name:

$ echo "$name" | tail -c -10

Reverse all lines in list:

$ tail -r list

Get Mac OS X Tiger in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.