
[英]How to use SED to remove texts starting from the first pattern until the second occurrence of the end pattern?
[英]SED/awk remove string until first occurrence
我有下面这样的字符串(中间有一排长线,中间有一个空格):
100">16946083;Rapid_0201_Corrected_Pre_Sept12thDate.txt;5744-2;RapidReporting;RR_20160606115224556.fin.bc_lerr.xml "100">16946083;Rapid_0201_Corrected_Pre_Sept12thDate.txt;5744;RapidReporting;RR_20160606115224556.fin.bc_lerr.xml
我想删除>
和;
之间的可变长度数字集;
在此示例中,这意味着删除(首次出现) 16946083
。
这段文字是我的sed
和cut
命令的输出。
怎么样
sed -e 's/>[0-9]\+;/>;/'
这将找到第一个>
任意数量的数字和;
并将整个字符串替换为>;
一个更强大的版本将是
sed -r 's/>[^;]+;/>;/'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.