trying to sum elements in an array using bc,i have a file with names and thier vaules if the names appears 3 times i should multiply its value with 3 then find the sum of all the elements together,im seeing standard input error
$ cat foo.txt
max 2.3
henry 3
fransis 4.5
max 2.3
henry 3
max 2.3
it should show on the terminal
max 6.9
henry 6
fransis 4.5
then
total 17.9
declare -A array
while read name value; do
array[$name]=$( echo "${array[$name]:-0} + $value" | bc )
done < cat foo.txt
for name in "${!array[@]}"; do
echo "$name ${array[$name]}"
done