I want to extract markdown from some sort of text (ulysses iii iCloud Text.txt file). The editor replaced all square brackets with the "OBJECT REPLACEMENT CHARACTER" 0xEF 0xBF 0xBC (efbfbc) and I want to undo this operation.
How can I substitute all odd occurrences with "[" and all others by "]".
EDIT:
As example I want to replace each occurrence of x to [or ]:
Some xlinkx -> Some [link]
You can use
sedfor your purpose. Withsed -iit will edit the file in place making the changes needed. To create a backup of the original infile.bakusesed -i.bak. The expression would require that you place the character you want to replace in the variablechar(e.g.char=xin your example). Then the following would replace all occurrence ofx..stuff..xwith[..stuff..]:Example:
The expression utilizes word boundaries
\bto control the match at the beginning and end of the experssion to insure first occurrence is replaced with[and the second with].