I am simply trying to replace text in bash, but having a hard time doing so. Other posts from years ago seem to result in an extremely complicated process, but I was hoping to get some easier and simpler assistance.
Here's the text that I have:
Here is a random sentence that contains [ABC-123](https://app.website.com/random/path/here?query=1) somewhere in the middle of it.
Here's what I'm trying to replace in the above text:
➜ ~ echo $replace_string
[ABC-123](https://app.website.com/random/path/here?query=1)
I am trying to replace it with this:
➜ ~ echo $replace_with
<https://app.website.com/random/path/here?query=1|[ABC-123]>
I am ultimately trying to convert Markdown interpreted by GitHub into Markdown that is interpreted by Slack (for whatever reason have their own way of doing this).
I have tried using sed, but this just does work because it keeps trying to interpret the replace strings as regex
➜ ~ echo $contents
Here is a random sentence that contains [ABC-123](https://app.website.com/random/path/here?query=1) somewhere in the middle of it.
➜ ~ echo $replace_string
[ABC-123](https://app.website.com/random/path/here?query=1)
➜ ~ echo $replace_with
<https://app.website.com/random/path/here?query=1|[ABC-123]>
➜ ~ echo $contents | sed "s/$replace_string/$replace_with/g"
sed: 1: "s/[ABC-123](https://app ...": RE error: invalid character range
Is there just a simple way to turn off regex interpretation in sed or another equivalent way using another utility? Other than modifying the text itself via sed, I am hoping to be able to use variables which hold the text, since the text will vary in many cases.