截取一段字符

来源:互联网 发布:农商银行柜员工资知乎 编辑:程序博客网 时间:2024/04/30 05:56

今天在处理mysqlbinlog的时候insert,和update 语句比较长换行比较多,有点类似于

要截取整段文字,如果截取

<phase a>
this is a test
hellow world     
</phase>


用下面的shell就可以处理整段文字,获取<phase a> 开头,</phase>结尾的一段

[root@rac1 ~]# sed -ne '/\<phase a\>/,/^<\/phase>/p' 1.txt
<phase a>
this is a test
hellow world     
</phase>


[root@rac1 ~]# sed -ne '/<phase a>/,/^<\/phase>/p' 1.txt
<phase a>
this is a test
hellow world     
</phase>

0 0
原创粉丝点击