Name

tail — stdin  stdout  - file  -- opt  --help  --version

Synopsis

tail [options] [files]

The tail command prints the last 10 lines of a file, and does other tricks as well:

tail myfile

The ultra-useful -f option causes tail to watch a file actively while another program is writing to it, displaying new lines as they are written to the file. This is invaluable for watching log files as they grow:

tail -f /var/log/messages

Useful options

-N

Print the last N lines of the file instead of the last 10.

-n N

Print the last N lines of the file instead of the last 10.

-n +N

Print all lines except the first N.

-c N

Print the last N bytes of the file.

-f

Keep the file open, and whenever lines are appended to the file, print them. This is extremely useful. Add the --retry option if the file doesn’t exist yet, but you want to wait for it to exist.

-q

Quiet mode: when processing more than one file, don’t print a banner above each file. Normally tail prints a banner containing the filename.

Get Macintosh Terminal Pocket Guide 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.