我需要从目录和子目录中的所有文件中删除(替换为空白)一个字符串。
但是该字符串包含特殊字符,例如 &?.<>/ (这是一个网址)! 我尝试使用 sed 和 rpl 但没有成功:无法转义字符。 要更改的字符串的 ex
<script src='https://test.com?type=in2&frm=scr&'></script>
尝试使用
时 rpl " <script src='https://test.com?type=in2&frm=scr&'></script>" "" index.php
我遇到了一个错误; NameError:名称“raw_input”未定义
我只需要知道如何在 sed 或 rpl 中转义这些 '/?.& 字符
最佳答案
it should DELETE the whole script line.
然后使用 grep
和 -v
。
$ cat <<'EOF' >/tmp/test.txt
a
<script src='https://test.com?type=in2&frm=scr&'></script>
b
EOF
$ grep -x -v "<script src='https://test.com?type=in2&frm=scr&'></script>" /tmp/test.txt
a
b
关于linux - 如何从许多文件中删除包含特殊字符的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55259912/