Tags

,

As an example, the following displays every first line and every 3rd line after that in a file file.txt:

$ awk 'NR%3==1' file.txt

So, if file.txt has 1 in the first line, 2 in the second and so on, then the above command will display 1 in the first line, 4 in the second, 7 in the third line and so on until it reaches the end of the file.

Advertisements