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.

Required fields*

6
  • 1
    We can't really help unless you provide example input and expected output. Do all target lines start with ## and a space? Can there be text after the (#some-title)? Why are you escaping th #? Most importantly, what OS are you using so we know what sed implementation you have? Commented Jul 18 at 9:42
  • Aside: Don't use -i in examples in questions or answers as then people reading them can't copy/paste your code to test it without trashing their input file. It's trivial for you to add -i (or do anything else that updates the input file) later if you want it. Commented Jul 18 at 11:41
  • Can Some title include (, ], #, ), or newlines? Please edit your question to tell us about that and to provide a few lines of truly representative sample input and the expected output given that input. Commented Jul 18 at 11:42
  • @terdon I added expected output if remove the link from Markdown was not clear enough. Commented Jul 18 at 21:15
  • You still didn't tell us if a title can include (, ], # or ) and so far have only provided 1 sunny-day example of an input line and no similar-looking lines you do not want modified so YMMV with how robust the answers you get are when exposed to your real data. Commented Jul 19 at 12:05