Let's say I have this data in a text file:
line1
line2
line3
line4
line5
...
I want to change this text file based on a pattern using line number e.g. line number mod 3,line contents:
1,line1
2,line2
3,line3
1,line4
2,line5
...
How can I achieve this (preferably using sed)?