O'Reilly logo

Mac OS X Tiger in a Nutshell by Jason McIntosh, Chuck Toporek, Chris Stone, Andy Lester

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required