sed 去除html代码,Sed regexp multiline - replace HTML

While @nhahtdh's answer is the correct one for your original question, this solution is the answer to your comments:

sed '

//,// {

1 {

s/^.*$/Replace Data/

b

}

d

}

'

You can read it like so:

//,// -> for the lines between these regexes

1 { -> for the first matching line

s/^.*$/Replace Data/ -> search for anything and replace with Replace Data

b -> branch to end (behaves like break in this instance)

d -> otherwise, delete the line

You can make any series of sed commands into one-liners with gnu sed by adding semicolons after each command (but it's not recommended if you want to be able to read it later on):

sed '//,// { 1 { s/^.*$/Replace Data/; b; }; d; };'

Just as a side note, you should really try to be as specific as possible in your posting. "replaced/removed" means "replaced OR removed". If you want it replaced, just say replaced. That helps both those of us trying to answer your question and future users who might be experiencing the same issue.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值