Easy Tutorial
❮ Linux Comm Reboot Linux Comm Compress ❯

Linux tail Command

Linux Command Manual

The tail command is used to view the contents of a file. A commonly used parameter is -f, which is often used to read log files that are being updated.

tail -f filename will display the last part of the content in the filename file on the screen and continuously refresh, allowing you to see the latest file content as soon as filename is updated.

Command Format:

tail [parameter] [file]

Parameters:

Examples

To display the last 10 lines of the notes.log file, enter the following command:

tail notes.log         # Default displays the last 10 lines

To track the growth of a file named notes.log, enter the following command:

tail -f notes.log

This command displays the last 10 lines of the notes.log file. As lines are added to the notes.log file, the tail command continues to display them. The display continues until you press (Ctrl-C) to stop it.

To display the contents of the notes.log file from line 20 to the end:

tail -n +20 notes.log

To display the last 10 characters of the notes.log file:

tail -c 10 notes.log

Linux Command Manual

❮ Linux Comm Reboot Linux Comm Compress ❯