- 论坛徽章:
- 0
|
我有如下格式的文本文件:
(cpId = 84,AbsPos = 229, omu, boardNum = 0, act.= Pas., FtState = Passive , OBR [Oc: 0 Rk: 1]),
(cpId = 66,AbsPos = 233, omu, boardNum = 1, act.= Act., FtState = Active , FT/LB [Oc: 0 Rk: 2]),
(cpId = 68,AbsPos = 233, omu, boardNum = 1, act.= Act., FtState = Active , SupCN [Oc: 0 Rk: 2]),
(cpId = 16,AbsPos = 193, tmu, boardNum = 0, act.= Act., FtState = Active , SS7 [Oc: 0 Rk: 1]),
(cpId = 17,AbsPos = 195, tmu, boardNum = 1, act.= Act., FtState = Active , TCUe3 [Oc: 0 Rk: 1]),
我想处理成下列格式,
(cpId = 84,XXXXXXXXXX, omu, boardNum = 0, act.= Pas., FtState = Passive , OBR [Oc: 0 Rk: 1]),
其中XXXXXXXX 为与AbsPos = ???相关的字符串。我有两个想法
1.建立一个文件
AbsPos = 225;XXXXXXXXXXXXXXX
AbsPos = 227;YYYYYYYYYYYYYYYYY
AbsPos = 228;ZZZZZZZZZZZZZZZ
然后在两个文件中查找替换,可是觉得这样效率很低
2.XXXXXXXXXXXX字符串可以根据AbsPos = Z 的Z 生成
大概算法:
if(Z>224) x="shel 1'+'slot '+z-224
else
x="shel 0'+'slot '+z-192
我可以通过类似
grep 'Ab' result|awk -F',' '{print $2}'|awk -F'=' '{if($2>224) print "CN1";if($2<224) print "CN0" }'
的shell来完成单列的转换,可是要完成替换却又做不了
有谁有更好的办法呢?
谢谢! |
|