TECH SOLUTIONS

Click here to edit subtitle

Forums

Post Reply
Forum Home > Unix Learnings > Print all lines except last 5 ------ head 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. 'head' command can be used to print top five lines as follows:

 

$ head -5 test

1

2

3

4

5

 $


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

$ head -n -5 test

1

2

3

4

5

6

7

8

9

10

11

$




--


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

You must login to post.