So I have got a file which contains lines like this :
Kiss Bea 3 4 5 4
Nagy Katalin 4 5 2 3
I ve tried this:
read name
while read var1 var2 var3
do
if [ $name == $var1 ]
then
echo $var3
fi
done < test.txt
name="Kiss"
so var3= 3 4 5 4 here
My problem is that I can’t put thoose numbers (which are in var3) into different variables because I need a script that writes out the average of those numbers.
One way like this in bash:
Replaced all the spaces with ‘+’ in var3 and the average was done using the bc command.