I am using the following script to read some numbers and calculate their average. However, it seems that floating point calculations cannot be performed like this.
hours=0
#echo "\n" >> user-list.txt
while IFS=, read -r col1 col2 col3 col4 col5 col6 col7 || [[ -n $col1 ]]
do
((hours = hours + col5))
#echo "$col1, $col2"
done < <(tail -n+2 user-list.txt)
((hours = hours/10))
echo "$hours" > wednesday.txt
How can I perform floating point calculations in this script?
Below is a sample of the input file:
Computer ID,User ID,M,T,W,T,F
Computer1,User3,5,7,3,5,2
Computer2,User5,8,8,8,8,8
Computer3,User4,0,8,0,8,4
Computer4,User1,5,4,5,5,8
TIA
awkto process your data. It can do floating point calculation.user-list.txt. This will allow us to test a proposed solution.