我没用那么多字段测试。
cat bts
BTS 20/1/0,1,0,1068,1.46,7,10520,7201,0,0,191,0.28,5,2014,7201,0,0,224,0.31,4,2263,7201,0,0
BTS 20/1/1,1,0,1068,1.46,7,10520,7201,0,0,191,0.28,5,2014,7201,0,0,224,0.31,4,2263,7201,0,0
BTS 20/1/2,1,0,1068,1.46,7,10520,7201,0,0,191,0.28,5,2014,7201,0,0,224,0.31,4,2263,7201,0,0
BTS 20/2/0,1,0,1068,1.46,7,10520,7201,0,0,191,0.28,5,2014,7201,0,0,224,0.31,4,2263,7201,0,0
BTS 20/2/1,1,0,1068,1.46,7,10520,7201,0,0,191,0.28,5,2014,7201,0,0,224,0.31,4,2263,7201,0,0
BTS 20/2/2,1,0,1068,1.46,7,10520,7201,0,0,191,0.28,5,2014,7201,0,0,224,0.31,4,2263,7201,0,0
- awk 'BEGIN{FS=OFS=",";f1="out1";f2="out2";f3="out3";n=10;fs="out"}
- /^BTS/{
- sub(/.* /,"",$1);gsub(/\//, ",", $1);
- for(i=1;i<=3;i++)printf $1""OFS>fs""i;
- for(i=2;i<=NF;i++){
- f=i>n&&i<2*n+1?f2:(i<=n?f1:f3);
- printf "%s%s", $i, i%n&&i<NF?",":"\n" >f
- }
- }' bts
复制代码 |