- 论坛徽章:
- 0
|
关于这个文本咋整?
- awk 'NR==FNR{ab1[$1]=$0}
- NR!=FNR{aa[$1]++;
- total[$1]=total[$1]"\n"$1" "ab1[$2];
- split(sum[$1],tmp1," ");
- split(ab1[$2],tmp2," ");
- sum[$1]=sprintf("%.2f %.2f %.2f\n",tmp1[1]+tmp2[2],tmp1[2]+tmp2[3],tmp1[3]+tmp2[4]);
- }
- END{
- for(i in aa)
- {
- if(aa[i]>=2)
- {
- print total[i];
- print sum[i];
- }
- }
- }'ab aa
复制代码
h 030301340000245 73730.93 0.00 73730.93
h 030301340000104 4639.58 0.00 4639.58
78370.51 0.00 78370.51
i 030301340012422 14822.99 0.00 14822.99
i 030301340000112 5302.40 0.00 5302.40
20125.39 0.00 20125.39
r 030301340000229 1922722.54 0.00 1922722.54
r 030301340000088 51488.22 0.00 51488.22
1974210.76 0.00 1974210.76
s 030301340000062 116098.83 0.00 116098.83
s 030301340000096 177444.50 0.00 177444.50
293543.33 0.00 293543.33
[ 本帖最后由 wmjie 于 2005-11-22 22:08 编辑 ] |
|