Sum the total based on ID

Hi

I am having a set of files which will have the card details and the amount that was spending on the card. Each file will have the set of cards and dollar amount spend on it. I am trying to sum the dollar values by card number on each files. Is there a way I do it all in all one steps

File 1:
4040011001;1;293;;;;;;;5450858.41;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011001;2;293;;;;;;;2244585.18;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011002;1;293;;;;;;;12117.55;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;1;293;;;;;;;650117.79;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;2;293;;;;;;;282250.40;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;3;293;;;;;;;34665.34;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;5;293;;;;;;;174916.29;;;;;;;;;;;;;;;;;;;;;;;;;;
File 2
4040011001;1;293;;;;;;;800990858.41;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011001;2;293;;;;;;;228999585.18;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011002;1;293;;;;;;;121232.05;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;1;293;;;;;;;650232.79;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;2;293;;;;;;;2822232.00;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;3;293;;;;;;;34.34;;;;;;;;;;;;;;;;;;;;;;;;;;
4040011003;5;293;;;;;;;14916.93;;;;;;;;;;;;;;;;;;;;;;;;;;

I will be having file file1,file2,file3 and upto 126 in the directory.

Output I want is sum the card and the dollars like below

4040011001 --   1037685887
 (5450858.41 +2244585.18+800990858.41+228999585.18).
also for 4040011002,4040011003

Things I tried.

 grep ^4040011001 file1 | cut -d  -f10 | paste -sd+ | bc

This will give me the individual sum. I want to calculate all card id with out doing a individual grep

Try

awk -F\; '{SUM[$1]+=$10} END {for (s in SUM) print s, "--", SUM}' OFMT="%.2f" file[12]
4040011001 -- 1037685887.18
4040011002 -- 133349.60
4040011003 -- 4629365.88
2 Likes