且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

替换"#"," $","%","&放大器;"和" _"与" \\#"," \\ $"," \\%QUOT;," \\&安培;"和" \\ _"

更新时间:2021-08-11 19:45:30

您可以做一个单一的电话更换为 SED

You can do the replacement with a single call to sed:

sed -i -E 's/([#$%&_\])/\\&/g' file.txt

&安培; 在替换文本填写的任何单个字符用括号括起来。请注意,由于 \\ 是LaTeX的转义字符,你必须逃脱它,以及在原始文件。

The & in the replacement text fills in for whichever single character is enclosed in parentheses. Note that since \ is the LaTeX escape character, you'll have to escape it as well in the original file.