Artificial intelligent assistant

Find total of marks for each student in the given file the file: Name: Rad Eng: 94 Tam: 98 Mat: 98 Soc: 98 Sci: 80 Name: Din Eng: 87 Tam: 89 Mat: 78 Soc: 87 Sci: 34 Name: Hardy Eng: 78 Tam: 87 Mat: 23 Soc: 34 Sci: 98 the script : #!/bin/bash file=$1 num=$2 n=`wc -l < $file` it=$((n/num)) echo $n echo $it awk -v numm="$num" '{if (NR<=numm){T+=$2}}END{print T}' $file My above script could generate total for first student. I want to find total for remaining two students marks also. Can someone help me with this?

You can search for `Name` and every time is found you go to the next `numm` lines and sum the scores:


#!/bin/bash
file=$1
num=$2
awk -v numm="$num" '
/Name/{
mark = 0;
printf("%s ",$2);
for ( i=0; i getline;
mark += $2;
}
printf("%d\
", mark);
}' $file


the result:


Rad 468
Din 375
Hardy 320

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy a02feb7b1732dd6037d000e5d5311ea6