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

前端 未结 4 1878
臣服心动
臣服心动 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:34

    I do not respond for sed, the other answers are good enougth ;-)

    You can use less as viewer to check your huge file (or more, but less is more comfortable than more).

    For searching, you can use fgrep: it ignores regular expression => fgrep '\$' will really search for text \$. fgrep is the same as invoking grep -F.

    EDIT: fgrep '\$' and fgrep "\$" are different. In the second case, bash interprets the string and will replace it by a single character: $ (i.e. fgrep will search for $ only).

提交回复
热议问题