problem while adding column values in awk
Hi,
I have a file "input.txt" with the following content :
5312,0,,,1,8,141.2,20090727
3714,0,,,1,8,285.87,20090727
5426,0,,,1,8,3.9,20090727
3871,0,,,1,8,30.4,20090727
9071,0,,,1,8,146.2,20090727
5141,0,,,1,8,2.8,20090727
0460,0,,,1,8,-0.1,20090727
7918,0,,,1,8,-0.1,20090727
1887,0,,,1,8,2,20090727
2083,0,,,1,8,22.8,20090727
6766,0,,,1,8,89.6,20090727
6001,0,,,1,8,2.3,20090727
9152,0,,,1,8,84.7,20090727
8138,0,,,1,8,31.9,20090727
1571,0,,,1,8,29.4,20090727
9730,0,,,1,8,408.7,20090727
8751,0,,,1,8,22.2,20090727
9015,0,,,1,8,983.7,20090727
6358,0,,,1,8,6.3,20090727
The 7th field contains both +ve and -ve values. I want to get the resultant sum all the values in the 7th field. I used the following awk command :
awk -F"," '{print $7}' input.txt | awk '{sum+=$1} END {print sum}'
I am getting this result : 5.29935e+06
How can i convert the result to a proper decimal value because i need the resultant value to be passed into another script as input.
---------- Post updated at 11:07 AM ---------- Previous update was at 11:05 AM ----------
Forgot to mention that the file "input.txt" contains about 40000 rows and the 7th field might have small values like 0.02 or 0.001 etc.