The code snippet below extracts values from an xml file and store totals for days 1 to 7 and a grand total for the last 7 days - $lsd. The day figures are 6 digit numbers with 3 decimal places. I cannot make the 'awk' function work. Everything I have tried produces either "0.000" or "". Changing the INC operator to simple addition gives similar results
Needless to say, I'm a complete newbie to Bash Arithmetic. Please can somebody tell me where I'm going wrong.
    for i in {1..7} ;
    do
        day=$(grep -oPm1 "(?<=<d00$i>)[^<]+" < data.xml) 
        printf "%.3f" $day > day$i.txt ;
        awk 'BEGIN{lsd += $day}' 
    done ;
    printf "%.3f" $lsd > lsd1.txt 
 
     
    