O'Reilly logo

Linux Pocket Guide, 2nd Edition by Daniel J. Barrett

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 — 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 in active use:

$ tail -f /var/log/messages

Useful options

-N

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

-n N

Print the last N lines of the file instead of 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.

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