- 论坛徽章:
- 60
|
回复 8# xierongzhong
靠! 暗黑西游是 4399 开发的啊,以为是 暗黑西游记 去了!我勒个去- [root@centos6-1 ~]#
- [root@centos6-1 ~]# cat file
- 神魔 S126
- 神魔 S125
- 神魔 S123
- 神魔 S109
- 神魔 S108
- 神魔 S107
- 神魔 S106
- 御剑 S125
- 御剑 S123
- 御剑 S109
- 御剑 S108
- 御剑 S107
- 御剑 S106
- 暗黑西游 S15
- 暗黑西游 S14
- 暗黑西游 S10
- 暗黑西游 S9
- 暗黑西游 S2
- [root@centos6-1 ~]#
- [root@centos6-1 ~]#
- [root@centos6-1 ~]# sort -tS -k2,2n file | awk -f f.awk
- 御剑 S106-109,S123,S125
- 神魔 S106-109,S123,S125-126
- 暗黑西游 S2,S9-10,S14-15
- [root@centos6-1 ~]#
- [root@centos6-1 ~]# cat f.awk
- #!/bin/awk
- { a[$1]=a[$1]?a[$1]","$2:$2 }
- END {
- for(i in a){
- for(n=1;n<=split(a[i],b,",");n++){
- m=0
- r=substr(b[n],1,1);t=substr(b[n],2);while(r""++m+t==b[n+m])continue;
- --m;if(m!=0)b[n]=b[n]"-"m+t
- s=s?s","b[n]:b[n]
- n+=m
- }
- print i,s;s=""
- }
- }
- [root@centos6-1 ~]#
复制代码 |
|