Hi Friends,
Can any one help me with count average of student marks in this file (i can not change structure of the input file):
input file:
1 - student ID
2 - student name
3 - group ID
4 - teacher ID
5 - marks (numbers of marks are different)
1:John Smith:2:3:2 3 4 5
2:Mark Anderson:2:1:3 2
3:Susan Waterman:2:2:2 4 2
output file:
Name:John Smith
ID#: 1
Avg. mark: 3.5
Name:Mark Anderson
ID#: 2
Avg. mark: 2.5
Name:Mark Anderson
ID#: 2
Avg. mark: 2.6667
Name:Susan Waterman
ID#: 3
Avg. mark: 2.5
Already I have this but it's not working because I add 2 columns so marks now are at 5 th column
awk -F: '{ n = split($NF, _, OFS)
for (i=1; i<=n; i++) s += _
printf "Name: %s\nID#: %d\nAvg. mark: %.1f\n\n",\
$2, $1, s/n; s = 0 }' input