CentOS Linux Server Guide

Displaying the end of file in CentOS Linux

Tail command is used to display the last few lines of a file.

  • The default number of lines displayed is 10

 

Name

tail

 

Synopsis

tail  filename(s)

tail -n filename(s)

tail +n filename(s)

 

Note:

-n option is number of lines that you want to display

+n option is to display a file starting at the X of lines

 

Scenario A

In the following example, the tail command (without using any option) will displaying the last 10 lines of the mail.log
tail mail.log

 

Scenario B

In the following example,  the tail -20 will displaying the last 20 lines of mail.log
tail -20 mail.log

 

Scenario C

In the following example, we are display from the 60th lines of mail.log
tail +60 mail.log

 

Scenario D

In the following example,  we are combining tail and head function.  We are displaying 5 lines start from 10th line.
tail +10 mail.log | head -5

 

Back to Managing Files and Folders in CentOS Linux

 



Copyright 2011 http://www.1a-centosserver.com All Rights Reserved

All trademarks are the property of their respective owners.

Contact Us | Terms of Use | Privacy Policy