Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • 2
    @SivaPrasath - not really, this will fail if the input contains consecutive lines matching PRIMARY Commented Sep 4, 2018 at 15:29
  • @don_crissti ur right!!! at least it works for the OP's input. Commented Sep 4, 2018 at 15:44
  • @don_crissti "not really" what? This is a solution for "Replace a string before a certain line" exactly as sed would do this on its own for the positive offset (AFTER a certain line/regex). You tried to judge the solution as for some other use case, not the one at hand. Commented Dec 11, 2022 at 19:06