Select specific line numbers

I have a file that contains 50,000 lines of floating values. I need to select only data every 100 rows. Is there any command in awk programming?

Thank you very much in advance.

+4
source share
2 answers

To print lines numbered 100, 200, 300 ... you can do:

awk 'NR%100==0' inputfile 

Take a look

+6
source

Alternative sed solution:

 sed -n '100~100p' file 

More generally, the expression A~Kp means printing every line of Kth starting at line A.

+1
source

All Articles