How do you perform floating-point math over variables in bash the output I get is an integer like number
#! /bin/bash 
# finding the average of n numbers 
avg=0
read -p "" n  
for (( i = 0; i < $n; i++ )) 
do 
    read x 
    ((avg = $avg + $x ))  
done
#printf %.3f "$(( avg / n ))  "
the goal is to show up to 3 decimal places
3
4
5
6
./avg.sh: line 22: printf: 5  : invalid number
5,000
I tried using | bc but I am missing sth
 
     
    