I'm having trouble on replacing the Nth line with "replaceString" within range-match in the sed command, i.e, is it possible to replace relatively the Nth line within range-match?
consider this input data:
1 a start 3 h 4 7 end 6 iii 7 4 and having this command:
sed '/start/,/end/ { *s/.*/replaceString/ }' in place of * in the above command how do I relatively say do command s/.*/replaceString/ say on 2nd line of the matched range? so it will give me following expected output.
1 a start replaceString 4 7 end 6 iii 7 4 this changes the second line absolute to the whole input file which is not what I want.
$ sed '/start/,/end/{ 2s/.*/replaceString/}' infile 1 a replaceString 3 h 4 7 end 6 iii 7 4 kindly note that I'm specifically want to do this in sed command to knowing how to relatively say line number for the matched range. the position (line number) of the start and end patterns are unknown.