Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat

This, of course is an answer to the original question,original question, not the modified one.

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat

This, of course is an answer to the original question, not the modified one.

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat

This, of course is an answer to the original question, not the modified one.

added 142 characters in body
Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat

This, of course is an answer to the original question, not the modified one.

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat

This, of course is an answer to the original question, not the modified one.

Source Link
ilkkachu
  • 147.9k
  • 16
  • 268
  • 441

Use the modulo (remainder) operator % on NR. NR % 100 would give 1,2,3...99,0,1,2..., so it needs a bit of tweaking. This should do:

awk '{ print (NR-1) % 100 + 1, $1 }' p2.dat > p3.dat