在<body ...> </body ...>之后插入Sed

时间:2013-11-20 20:46:17

标签: regex bash sed

我想在打开<body...>标记后添加一行html,但是没有任何新行,所以这对我来说有点困难。

例如,我想在<p>This is the first line</p>标记之后插入我在文本文件中调用的<body...>

<html><head><title>Some title</title></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Some text goes here

到目前为止,我尝试的所有内容仅在匹配字符串的第一个换行符后插入。当身体造型总是不同时,如何在身体后插入?

1 个答案:

答案 0 :(得分:5)

不建议用sed操纵HTML。但是你可以尝试:

sed -i.bak 's~<body[^>]*>~&<p>This is the first line</p>~' file.html
相关问题