Hello All!
As a beginner user i want to add up sequential values in a text file and want to print total sum as output.The Text file will have values like the following:
class1{root}>less SUM.txt
1140.00 1155.00 1183.00 ... # it continues #
i tried to write a script with for-do looping and awk inside the loop but it didnt work (not a surprise to me ) And i dont know how to end up the looping as it should detect the last value in file (for ex: if there is 5 values it should stop when AWK detects that 6th value is zero). Could you help me please..
for (( i=1; i<=100; i++ )) do
cat SUM.txt | awk '{total += $i} END {printf "%15.2f\n",total}'
if [ "$awk'{printf "%15.2f\n",total}" -eq 0 ]
then break ## or end up the loop and print the result ##
fi
done