I currently have a problem when editing my manuscript.tex
files. So far I have always used the text short-hand $$; however, something comes up and it requires me to replace all $...$ by \( \)
.
I think "sed" with replacement operation should be a right tool for the task. However, I am not good or familiar with "sed" and regular expression. Therefore, I need hints and helps for doing this.
Supposed the input file is named as manuscript.tex
. I need "sed" to replace $ e=mc^2 $
with \( e=mc^2 \)
. How can I do this ?
If there is never a newline between the dollar signs, you can try something like
sed -e 's/\$\([^$]\+\)\$/\\(\1\\)/g' manuscript.tex > manuscript2.tex
Other way using sed
sed -re 's/(.*)\$(.*)\$(.*)/\\(\2\\)/g' temp.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With