Linux 查找并替换.htaccess代码

Linux 查找并替换.htaccess代码,linux,bash,replace,find,centos,Linux,Bash,Replace,Find,Centos,我想在/home目录下的所有.htaccess文件和目录中查找和删除代码 RedirectMatch \.(dynamiccontent|pl|plx|perl|cgi|php|php4|php4|php6|php3|shtml)$ http://domain.com/cgi-sys/movingpage.cgi bash命令是什么来完成这项工作的 编辑: 我试过这个命令 find /home*/*/public_html/ -mindepth 1 -iname "\.htaccess" -t

我想/home目录下的所有.htaccess文件和目录中查找删除代码

RedirectMatch \.(dynamiccontent|pl|plx|perl|cgi|php|php4|php4|php6|php3|shtml)$ http://domain.com/cgi-sys/movingpage.cgi
bash命令是什么来完成这项工作的

编辑:

我试过这个命令

find /home*/*/public_html/ -mindepth 1 -iname "\.htaccess" -type f -exec grep -Hi "RedirectMatch*" '{}' \;

但此命令仅查找代码,而不是删除代码,同时查找所有重定向匹配代码,而不是我在第一个问题中提到的特定代码您可能可以尝试此sed命令:

sed -i.bak '/RedirectMatch \\\.(dynamiccontent/d' .htaccess

是否要删除所有
RedirectMatch
行?否,我只想删除此行,其他中还有另一个RedirectMatch代码。htaccess我不想删除所有RedirectMatch代码,但是只有这一个这项工作可以很好地删除代码,但是我如何在一个命令中执行命令查找和删除代码呢?这实际上是在单个命令中进行查找和替换,因为
-i
switch.find/home*/*/public\u html/-mindepth 1-iname“\.htaccess”-type f-exec-sed-i.bak'/RedirectMatch\\\。(dynamiccontent/d'{}\;感谢@damienfrancois的评论