Print lines after every n lines in a file

Sunday, December 30, 2012 0 Comments


Input has these lines:

    line 1 
    line 2
    line 3
    line 4 
    line 5
    line 6
    line 7
    line 8
    line 9
    line 10

how to write a script that prints only every 4 lines, in the case of the example input above:

    line 1
    line 5
    line 9

Solution for this is:

awk 'NR % 4 == 1'

0 comments: