Untitled Document
tail Command

The tail command complements the head command . The tail command displays the end of the file . It provides an additional method of addressing lines and like head , it displays last ten lines by default .

1. Basic Example -

Run below tail command it will display last ten lines from emp.csv .

   tail emp.csv   

2. Displaying the selected line numbers ( -n ) option

Below tail command displays last 15 lines from user.txt

   tail -n 15 user.txt 

3. Addressing lines from begining of file ( + ) option -

We can also address lines from begining of the file instead of end .The +n option allows us tto do that , where n represent the line number from where the selection should begin . The below command select lines from line number to end .

   tail +5 emp.csv 

4. Monitoring File ( -f ) option -

Many UNIX / LInux programs constantly write to the system's log file as long as they are running . System administrator need to monitor the growth of these files to view the latest messages . tail offers the -f ( follow) option for this purpose . This is how you can monitor the execution logs .

   tail -f server.txt

The prompt doesn't return even after the work is over . With this , option we have to use the interurupt key to abort the process and exit to the shell

use tail -f when you are running a program that continuously writes to a file , and you want to see how the file is growing . We have to terminate this command with the interupt key .
Untitled Document