I want to transform a line that looks like this:
any text #any text# ===#text#text#text#===#
into:
any text #any text# ===#texttexttext===#
As you can see above I want to remove the # between ===# and ===#
The number of # that are supposed to be removed can be any number.
Can I do this with sed?
Give this a try:
It splits the line in two at the first “=#”, then deletes all “#” that aren’t preceded by an “=”, then recombines the lines.
Let me know if there are specific cases where it fails.
Edit:
This version, which is increasingly fragile, works for your new example as well as the original: