I’m having trouble creating 2 commands that insert one word (different between the commands) at the beginning of every line with step = 2.
For example:
Before:
10
10
10
10
After:
group1 10
group2 10
group1 10
group2 10
So what I would want is that 1 command starts inserting the word ‘group1’ to every odd line, while the second command inserts the word ‘group2 to every even.
The number 10 is chosen randomly as a substitute for my data numbers
Hope you could help me with this.
Cheers,
You can do this with sed, here handling odd and even lines separately:
The 1~2 matches every second line starting with first, and 2~2 matches every second line starting from second. “s” substitutes, “^” matches the start of the line