2012-03-01 56 views
0

鉴于我有以下源的TWiki页面:返回一个正则表达式匹配不包括比赛的部分

| *Region* | *Owner* | *Partner/Project* | *Type* | *Description* | *Timeline* | *Flag* | *Update* | 

| Region 1 | Olaf | RedHat | type1 | nothing to do at topic 1 | time1 | Progress | TBC | 

| Region 2 | Olaf | Gentoo | type2 | nothing to do at topic 2 | time2 | | none | 

我想构建后应

更新匹配一切正则表达式模式* |

这是一个简单的问题,伙计!

+1

但有什么更新后'* |'。你能发布你想要的输出吗? – kev 2012-03-01 15:58:54

+0

|区域1 |奥拉夫| RedHat | type1 |在主题1 |无关time1 |进展| TBC | |区域2 |奥拉夫| Gentoo | type2 |在主题2 |无关time2 | | none | – nottinhill 2012-03-01 16:06:12

+0

为什么不删除第一行?剩下的就是你想要的,我想。 – kev 2012-03-01 16:10:04

回答

0

如果你的egrep在* nix中的意思是egrep的二进制文件,那么你可以这样做:

egrep -o "\*Update\*.*" <<< $(<file) 

OUTPUT:

*Update* | | Region 1 | Olaf | RedHat | type1 | nothing to do at topic 1 | time1 | Progress | TBC | | Region 2 | Olaf | Gentoo | type2 | nothing to do at topic 2 | time2 | | none | 
0

这是你想要什么?

awk 'o;/\*Update\* \|$/{o=1}' yourFile 

输出

| Region 1 | Olaf | RedHat | type1 | nothing to do at topic 1 | time1 | Progress | TBC | 

| Region 2 | Olaf | Gentoo | type2 | nothing to do at topic 2 | time2 | | none |