本帖最后由 personball 于 2012-06-28 10:50 编辑
- personball@vostro:awk$awk -F, '{if(!a[$1","$2]){a[$1","$2]=$0}else{a[$1","$2]=a[$1","$2]","$3","$4}}END{for(i in a)print a[i] }' TEST3
- 0001,ChinaUnix论坛真是不错,01,0,02,0,03,0,04,0,05,0
- personball@vostro:awk$cat TEST3
- 0001,ChinaUnix论坛真是不错,01,0
- 0001,ChinaUnix论坛真是不错,02,0
- 0001,ChinaUnix论坛真是不错,03,0
- 0001,ChinaUnix论坛真是不错,04,0
- 0001,ChinaUnix论坛真是不错,05,0
- personball@vostro:awk$
复制代码 回复 1# 有点浪有点漫 - personball@vostro:awk$awk -F, '{t=$1","$2; if(!a[t]){a[t]=$0}else{a[t]=a[t]","$3","$4}}END{for(i in a)print a[i] }' TEST3
- 0001,ChinaUnix论坛真是不错,01,0,02,0,03,0,04,0,05,0
- personball@vostro:awk$
复制代码 |