Replacing “#”, “$”, “%”, “&”, and “_” with “\#”, “\$”, “\%”, “\&”, and “\_”

前端 未结 4 1874
臣服心动
臣服心动 2020-12-31 10:02

I have a plain text document, which I want to compile inside LaTeX. However, sometimes it has the characters, \"#\", \"$\", \"%\", \"&\", and \"_\". To compile properly

4条回答
  •  清酒与你
    2020-12-31 10:43

    I think your problem is that bash itself is handling those escapes.

    1. What you have looks right to me. But warning: it will also doubly escape e.g. a \# that is already escaped. If that's not what you want, you might want to modify your patterns to check that there isn't a preceding \ already.
    2. $ is used for bash command substitution syntax. I guess grep "\\$" file.txt should do what you expect.

提交回复
热议问题