I have a document containing many percent, plus, and pipe signs. I want to replace them with a code, for use in TeX.
%becomes\textpercent.+becomes\textplus.|becomes\textbar.
This is the code I am using, but it does not work:
sed -i "s/\%/\\\textpercent /g" ./file.txt
sed -i "s/|/\\\textbar /g" ./file.txt
sed -i "s/\+/\\\textplus /g" ./file.txt
How can I replace these symbols with this code?
Test script:
Output:
This was already suggested in a similar way by @tripleee, and I see no reason why it should not work. As you can see, my platform uses the very same version of GNU sed as yours. The only difference to @tripleee’s version is that I use the extended regex mode, so I have to either escape the pipe and the plus or put it into a character class with
[].