Skip to content
HxHippy

tail

Output the last part of files

Overview

Prints the last 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name.

Syntax

tail [OPTION]... [FILE]...

Common Options

-n, --lines=[+]K

Output the last K lines, instead of the last 10; or use -n +K to output lines starting with the Kth.

-c, --bytes=[+]K

Output the last K bytes; or use -c +K to output bytes starting with the Kth of each file. (K may have a multiplier like head).

-f, --follow[={name|descriptor}]

Output appended data as the file grows.

-F

Same as --follow=name --retry. Useful if the file may be rotated or renamed.

-q, --quiet, --silent

Never output headers giving file names.

-v, --verbose

Always output headers giving file names.

--pid=PID

With -f, terminate after process ID, PID, dies.

Examples

$ tail myfile.txt

Displays the last 10 lines of myfile.txt.

$ tail -n 20 error.log

Displays the last 20 lines of error.log.

$ tail -n +5 data.csv

Displays all lines of data.csv starting from the 5th line.

$ tail -c 50 access.log

Displays the last 50 bytes of access.log.

$ tail -f /var/log/syslog

Continuously monitors /var/log/syslog for new lines (useful for live log viewing).

$ dmesg | tail -n 20

Shows the last 20 kernel messages.

tailendlastlinesfiletextlogfollow