Linux Tail

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Linux tail

The 'tail' command displays the last lines of a file. Its main purpose is to read the error message.

By default, it will also display the last ten lines of a file.

Syntax:

tail <file name> 

Example:

tail jtp.txt 

Linux File tail

Look at the above snapshot, last ten lines of the file 'jtp.txt' is displayed with the help of command "tail jtp.txt".


Linux tail -n

The 'tail -n' option displays the specified number of lines.

Syntax:

tail -n<number> <file name> 

Example:

  1. tail -n5 jtp.txt  

Linux File tail n

Look at the above snapshot, the last five lines of the file 'jtp.txt' is displayed with the help of "tail -n5 jtp.txt" command.


tail -c

The 'tail -c' option displays the specified number of bytes from the last.

Syntax:

tail -c<number> <file name>

Example:

tail -c12 jtp.txt

Linux File tail c

Look at the above snapshot, the last 12 bytes of file 'jtp.txt' is displayed with the help of "tail -c12 jtp.txt" command.