TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Unix Learnings > Print all lines except top 5 - tail command

Sourav Gulati
Site Owner
Posts: 83

Here is a test file :

$ cat test

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

$

Now. 'tail' command can be used to print last five lines as follows:

$ tail -5 test

12

13

14

15

16

 $

Lets say our while reading output of a log file, our requirement  is to print all lines except top five lines , then also 'tail' command can help as follows:

$tail -n +6 test

6

7

8

9

10

11

12

13

14

15

16

$

Note , here numeric value ( '+6' in the previous example) should be 'number of lines you want to skip from top + 1'



 

 

 

 

 

 

 

 

--


August 21, 2012 at 1:52 AM Flag Quote & Reply

You must login to post.