I'm trying to study for a test and one of the subjects are bash scripts. I have the following txt file :
123456 100
654321 50
203374111 86
I need to get the averages of the scores (the numbers in the second column).
This is what I have written :
cat $course_name$end | while read line; do
sum=`echo $line | cut -f2 -d" "`
let total+=$sum
done
I have tried with
while read -a line
and then
let sum+=${line[1]}
But I'm still getting the same error mentioned in the header.
cut;readcan handle the word splitting for you withwith read id sum; do let total+=sum; done.idis just a placeholder for whatever the first column is.