I have a data file like this
1.59949146E+01 1.59949146E+01 1.59949146E+01 1.59949146E+01 1.59949146E+01
1.59949146E+01 1.59949146E+01 1.59949146E+01 1.59949146E+01 1.59949146E+01
1.59949146E+01 1.59949146E+01 2.39850450E+01 2.39850450E+01 2.39850450E+01
2.39850450E+01 2.39850450E+01 2.39850450E+01 2.39850450E+01 2.39850450E+01
2.39850450E+01 2.39850450E+01 2.39850450E+01 2.39850450E+01
To sum all the numbers, I use the following code
awk '{ for(i=1;i<=NF;i++){ print $i}}' number.txt |awk '{printf ("%f ", $0)}' |awk '{ for(i=1;i<=NF;i++){ print $i}}'|paste -sd+ | bc
First, it changes all raws to a single column
awk '{ for(i=1;i<=NF;i++){ print $i}}' number.txt
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
1.59949146E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
2.39850450E+01
Using awk '{printf ("%f ", $0)}' I will have the following output
15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 15.994915 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045 23.985045
Again I need to use awk '{ for(i=1;i<=NF;i++){ print $i}}' to convert raws to a column and then using paste -sd+ | bc I can have the answer
479.759520
Although it works I'm looking for a better way to reduce the steps.