我有多个文件" header.php"在多个目录中。 其中一些包含字符串" ASDF1234"其中一些没有。
我想搜索所有" header.php"文件包含字符串" ASDF1234"并删除包含它的整行。
我怎么能用sed做到这一点?
答案 0 :(得分:3)
您也可以尝试这种方式
find -iname "header.php" -exec sed -i '/ASDF1234/d' {} \;
<强>解释强>
find -iname "header.php" - It will find all header.php files
-exec - Execute the sed command and passing the argument for all the header.php files
sed -i '/ASDF1234/d' - If the /ASDF1234/ content match delete the line.