Skip to main content

Timeline for Replace Nth line after match

Current License: CC BY-SA 4.0

22 events
when toggle format what by license comment
Jul 29, 2021 at 0:57 vote accept cjijcb
Jul 29, 2021 at 0:56 vote accept cjijcb
Jul 29, 2021 at 0:57
May 24, 2021 at 11:59 answer added DanieleGrassini timeline score: 0
May 14, 2021 at 18:35 answer added user232326 timeline score: 6
May 14, 2021 at 18:07 answer added D. Ben Knoble timeline score: 4
May 14, 2021 at 13:47 comment added Ed Morton Another edge case to consider - what if the string you're adding contained the string you're searching for, e.g. instead of MODIFIED it were fifty-two? Should THAT line then match with two and so you'd change the 5th line after THAT and every 5th line from then on?
May 14, 2021 at 13:33 comment added Ed Morton Just use 10 lines of sample input/output instead of 500 and show us what the output should be if you want to print the 5th lines after every line that contains t. Different answers you have will give you the same output for two but different output for t. It would also be good if you showed if you want a regexp or string match.
May 14, 2021 at 12:38 answer added Philippos timeline score: 0
May 14, 2021 at 12:10 answer added Stéphane Chazelas timeline score: 10
May 14, 2021 at 11:59 answer added Ed Morton timeline score: 4
May 14, 2021 at 9:34 history became hot network question
May 14, 2021 at 5:04 history edited αғsнιη CC BY-SA 4.0
edited tags; edited title
May 14, 2021 at 5:00 comment added αғsнιη @Quasímodo OK, but there end could be replaced with $, so for example seq 10|sed '/2/,${/2/,+5{/2/,+4!s/.*/replaceString/}}' from accepted answer or seq 10| sed '/2/{:a;N;$!ba;s/[^\n]*/replaceString/6}' from the second answer. no such big difference, but easy adjustable if one could understood how they works. BTW, I retracted my close vote.
May 14, 2021 at 3:09 answer added guest_7 timeline score: 2
May 14, 2021 at 2:27 review Close votes
May 14, 2021 at 5:05
May 14, 2021 at 2:10 answer added Quasímodo timeline score: 7
May 14, 2021 at 2:07 comment added αғsнιη Does this answer your question? Relative line number in the range match in sed
May 14, 2021 at 2:06 answer added Freddy timeline score: 13
May 14, 2021 at 1:52 history edited cjijcb CC BY-SA 4.0
deleted 2 characters in body
May 14, 2021 at 1:46 history edited cjijcb CC BY-SA 4.0
added 3 characters in body
May 14, 2021 at 1:41 review First posts
May 14, 2021 at 8:44
May 14, 2021 at 1:32 history asked cjijcb CC BY-SA 4.0