相关疑难解决方法(0)

sed multiline替换

这是我的示例文本文件:

asdas
//<<<TAG
this should be removed
//TAG>>>
this should be there
//<<<TAG
T
>
asd
asd
//TAG>>>

我希望o/p为:

asdas

this should be there

基本上我试图找到"// << >>"之间的行(包括这些行)并删除它们.

我尝试使用sed

sed -n'1h; 1!H; $ {; g; s /// <<]*TAG >>> // g; p;}'<test.txt

但有些人如何没有产生正确的输出.正则表达式中包含">"符号的第二个标记失败.不知道我哪里出错了?

知道怎么做吗?

sed multiline

15
推荐指数
1
解决办法
2万
查看次数

标签 统计

multiline ×1

sed ×1