日期:2014-05-16 浏览次数:20830 次
[seesea@CSDN ~]$ cat file
1,2851070,1373762396622
1,2851070,1373764594902
13,2851070,1373762396630
13,2851070,1373764594910
16,2851070,1373762396628
16,2851070,1373764594908
17,2851070,1373764594912
21,2851070,1373762396626
21,2851070,1373764594906
22,2851070,1373764594914
9,2851070,1373762396624
9,2851070,1373764594904
[seesea@CSDN ~]$ awk -F',' 'ar[$1","$2] < $3 {ar[$1","$2] = $3}; END{for(i in ar) print i "," ar[i]}' file
17,2851070,1373764594912
16,2851070,1373764594908
1,2851070,1373764594902
22,2851070,1373764594914
13,2851070,1373764594910
21,2851070,1373764594906
9,2851070,1373764594904
sort -t, -k3nr urfile
------解决方案--------------------
awk -F, -v OFS=',' '!a[$1,$1]++'
sort -t, -k3nr urfile
------解决方案--------------------
awk -F, -v OFS=',' '!a[$1,$1]++'