I have a plain text
file with LaTeX
commands like \hspace{5cm}
. To convert this file to .odt
some of my custom commands are not converted correctly. So I want to automatically find & replace specific commands but keep the content of the brackets (meaning that I want to keep most of the commands and just delete some). I know that I can just open gedit
and do the replacing by hand, but this is for a script for repeated, automatic replacement.
I already searched for this, but so far only found answers to delete brackets while keeping there content (cf. here, here)). I also looked at some introductions to sed
(e.g. here or here) without any success.
Example:
This is my \textbf{text} where there are about \prc{5} commands, i.e. \mErrRange{30}{20}{m}.
So, since these are a percentage and an error range, I want to delete the command & curly brackets and get something like this (keeping the \textbf{...}
command):
This is my \textbf{text} where there are 5 % commands, i.e. 30 ± 20 m.
What I tried so far:
Various ways to usesed
, like:
sed -i -e 's/\\prc{\(.*\)}/\1%/g' hello.txt
This already gives me:
This is my \textbf{text} where there are about 5} commands, i.e. \mErrRange{30}{20}{m%.
(Replacing the last curly bracket in the line, but leaving the other one in its place.)
So, now I have no clue how to continue with that. Maybe I should use another tool instead of sed
?! I am happy about any suggestion running on Ubuntu & in the terminal
without installing too much.