I am trying to compute the sum of the travel distance and it is computed perfectly in the text file. However, the results would be rounded off to 4 decimal places
For instance, whenever I tried to add 10.1361234 and 10.1461621 meters from Distance Log, instead of showing the original result of 20.2822855, the result will be rounded off as shown below
totaldistance.txt
2021-04-09 13:44:26 Total distance: 20.2823 meters
DistanceLog.txt
2021-04-09 12:31:55 Distance travelled: 10.1361234 meters
2021-04-09 12:31:55 Distance travelled: 10.1461621 meters
However, I wanted to keep the original decimal values without rounding off. Is there any way to do it? Attached below is my code
#!/bin/bash
SUM=0;
<DistanceLog.txt >> totaldistance.txt awk '{ SUM+=$6 } END{ print date_time,echo"Total distance:", SUM,distance }' date_time="$(date +'%F %T')" distance="meters"
Thank you!