I want to see just last sum here, but it shows me everything.
awk '{print sum += $1} END {print sum}' file.dat This is the output:
1.2 3.6 7.3 7.3 31 Answer
Considering you want sums in file.dat added together and then print them out, the line should be:
awk '{sum +=$1} END {print sum}' file.dat Telling awk to print the sum every time you add a new value to sum makes it show each intermediate value, just as you have experienced.