Vijay
Vijay

Reputation: 985

selecting specific line numbers

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

Many thanks in advance.

Upvotes: 5

Views: 1788

Answers (2)

dogbane
dogbane

Reputation: 274532

Alternative, sed solution:

sed -n '100~100p' file

More generally, the expression A~Kp means print every Kth line starting with line A.

Upvotes: 1

codaddict
codaddict

Reputation: 454960

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

awk 'NR%100==0' inputfile

See it

Upvotes: 7

Related Questions