Hi guys/gals i have a quick question. I am trying to read from a file and add the values up but the problem is the values are not integers their floats so i tried to used bc but failed epicly lol. Any tips would be great. Thanks
this is the code i have so far :
while read num
do
total=$(echo "scale=2; $num + $total" | bc)
done < <(cat file.txt)
echo "Total: " $total
i figured the heading wouldn't affect the read in unless im mistaken but i could easily remove that. And the spaces could be taken out using sed '/^$/d' file.txt
so im still having trouble with reading from the file and using bc. I keep getting parse error.