我想替换每个引用的可打印换行符,但只能在第一次出现特定单词后才会替换。
示例:
blabla=
test
--69c1683a3ee16ef7cf16edd700694a2f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<title>Testing Manuel Lemos' MIME E-mail composing and sending PHP class: H=
TML message</title>
<style type=3D"text/css"><!--
body { color: black ; font-family: arial, helvetica, sans-serif ; backgroun=
d-color: #A3C5CC }
A:link, A:visited, A:active { text-decoration: underline }
--></style>
</head>
<body>
<table background=3D"cid:4c837ed463ad29c820668e835a270e8a.gif" width=3D"100=
%">
<tr>
<td>
<center><h1>Testing Manuel Lemos' MIME E-mail composing and sending PHP cla=
ss: HTML message</h1></center>
<hr>
<P>Hello Manuel,<br><br>
This message is just to let you know that the <a href=3D"http://www.phpclas=
ses.org/mimemessage">MIME E-mail message composing and sending PHP class</a=
> is working as expected.<br><br>
<center><h2>Here is an image embedded in a message as a separate part:</h2>=
</center>
<center><img src=3D"cid:ae0357e57f04b8347f7621662cb63855.gif"></center>Than=
k you,<br>
mlemos</p>
</td>
</tr>
</table>
</body>
</html>
--69c1683a3ee16ef7cf16edd700694a2f--
到目前为止,我正在使用此sed命令:
sed ':a;N;$!ba;$s/=\n//g'
结果:
blablatest
--69c1683a3ee16ef7cf16edd700694a2f
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<title>Testing Manuel Lemos' MIME E-mail composing and sending PHP class: HTML message</title>
<style type="text/css"><!--
body { color: black ; font-family: arial, helvetica, sans-serif ; background-color: #A3C5CC }
A:link, A:visited, A:active { text-decoration: underline }
--></style>
</head>
<body>
<table background="cid:4c837ed463ad29c820668e835a270e8a.gif" width="100%">
<tr>
<td>
<center><h1>Testing Manuel Lemos' MIME E-mail composing and sending PHP class: HTML message</h1></center>
<hr>
<P>Hello Manuel,<br><br>
This message is just to let you know that the <a href="http://www.phpclasses.org/mimemessage">MIME E-mail message composing and sending PHP class</a> is working as expected.<br><br>
<center><h2>Here is an image embedded in a message as a separate part:</h2></center>
<center><img src="cid:ae0357e57f04b8347f7621662cb63855.gif"></center>Thank you,<br>
mlemos</p>
问题是,
blabla=
test
也变成了
blablatest
所以我希望sed命令只在第一次出现“html”后执行。 我试过了:
sed ':a;N;$!ba;/html/,$s/=\n//g'
但它不起作用。
答案 0 :(得分:1)
在命令前移动/<html>/
地址:
sed '/<html>/{:a;N;$!ba;$s/=\n//g}' file