Wednesday, 24 April 2013

Unix:Print all lines except top 5 lines of a file - tail command


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'

No comments:

Post a Comment