Bash删除后的所有内容

时间:2012-12-21 17:35:06

标签: replace sed

我的一个客户网站遭到入侵,每个文件都有iframe注入。但是,iframe注入始终在结束</html>标记之后。

是否有一种简单的方法可以使用Bash删除</html>标记之后的所有内容,例如sed?

E.g:

</html>
p
<nofollow><iframe src="http://xxxxx.com/local.html" width="0" height="0" frameborder="0"></iframe></nofollow>
p
<nofollow><iframe src="http://xxxxx.com/local.html" width="0" height="0" frameborder="0"></iframe></nofollow>

2 个答案:

答案 0 :(得分:6)

当您点击该线时退出:

sed -i '/<\/html>/q' file

答案 1 :(得分:2)

这就是你要找的东西:

 sed -i '/<\/html>/,$d;$a <\/html>' yourfile

已更新,删除行直至文件末尾