help.. Problems in using awk

I do have a file (named as templist) which looks like this one:
00450000.000000 00402300.000000 00040000.000000 00020000.000000 00020000.000000 00020000.000000 00020000.000000

and I want to make a script that adds this using AWK or FOR.
I tried using awk using the command

but it just returns the value of the first variable 450000.

please help me to modify my command.
thanks

$ echo 00450000.000000 00402300.000000 00040000.000000 00020000.000000 00020000.000000 00020000.000000 00020000.000000 \
| awk -v RS=" " '{sum=sum+$1;printf("sum: %.0f\n",sum)}'
sum: 450000
sum: 852300
sum: 892300
sum: 912300
sum: 932300
sum: 952300
sum: 972300

thanks for this

this outputs:

is it possible to output only the final result in the file "sum: 972300"

remove the cat. Use the END {} block

awk -v RS=" " '{sum=sum+$1} END { .... }'  templist > total

i tried using this one:

but its giving me an error

please help me in fixing this.

xtest> awk '{ for (i=1;i<=NF;i++)sum+=$i ; printf("sum: %.0f\n",sum)}' dakid
sum: 972300

thank you all for great help.

it seems that there is an issue if there are more numbers of lines added... seems that the output becomes zero.
please help me

kindly disregard this inquiry... i've found out that the code works well, but the problem is somewhere else :slight_smile: