Count column data in a text file

I have a text file that has the following column data:

0.007
0.005
0.004
0.007

How do i output the total sum of the data above?

Try this:

awk '{sum+=$1} END {print sum}' file
2 Likes

Try this:

cat file | awk '{ sum+=$1} END {print sum}'
2 Likes

You have won "Useless use of cat award"!!!!!

thanks all.

Thanks Rangarasan. I will take this as a part of motivation and correct my mistakes.

To err is human :wink:

All is well :slight_smile: Good spirit :slight_smile: