You're viewing a comment by Fatih M. KILIÇ and its responses.

January 13, 2016, 07:30

Hello, I want to get the line in file with a specific range. For instance, inclusive 8th. 18th. 28th. print the line .... end of file.
My code is:
awk '{ for (NR=8; NR <= 118; NR=NR+10) print; exit }' input.txt
Where is the my fault? This code repeat same lines six times.

Comment Responses

vaishali Permalink
January 15, 2016, 13:55

Fatih;
Awk '{a=NR/8;b=int(NR/8); if ( a == b ){ print;}; }' input.txt

Fatih M. KILIÇ Permalink
June 30, 2016, 11:42

Thanks for your response. But, this code getting the lines like this 8. 16. 24. ....

I'd like to 8 , 18, 28, 38.. lines. So, like 8x+10 formula.

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "unix_122": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.