小编Mar*_*oen的帖子

sed:替换每一行中第一次出现的字符串

想象一下我有一个这样的文件:

INSERT INTO table VALUES('1','<p><em>The lazy fox jumps again</em></p>bunch of other html<p><em>Is the lazy fox crazy?</em></p>')
INSERT INTO table VALUES('2','<p><em>The lazy fox jumps again</em></p>bunch of other html<p><em>Is the lazy fox crazy?</em></p>')
INSERT INTO table VALUES('3','<p><em>The lazy fox jumps again</em></p>bunch of other html<p><em>Is the lazy fox crazy?</em></p>')
Run Code Online (Sandbox Code Playgroud)

我想删除只有第一次出现的<p><em></em></p>,所以我最终的东西是这样的:

INSERT INTO table VALUES('1','The lazy fox jumps againbunch of other html<p><em>Is the lazy fox crazy?</em></p>')
INSERT INTO table VALUES('2','The lazy fox jumps againbunch of other html<p><em>Is the lazy fox …
Run Code Online (Sandbox Code Playgroud)

sed find-and-replace

5
推荐指数
1
解决办法
5669
查看次数

标签 统计

find-and-replace ×1

sed ×1