Hi, i need some help plz...
The file data.txt contains: code of student,surname and name,code of lesson,grade of lesson.The number of lessons of each student is not the same.
25,Jackson Steve,12,4,34,2,65,2
29,Jordan Mary,13,6,23,8,56,4,34,2
04,Leven Kate,14,6,15,6,26,4
34,Owen Chris,85,6,39,4,42,6,65,8,12,6
I want to find the avg for lessons that the grade is >=5.
This command:
cat data.txt | awk -F, '{for (i=4;i<=NF;i+=2)if($i>=5) printf $i" ";printf"\n"}'
cats grades of students >=5.
How to find avg ? I want to cat this result:
Jordan Mary avg 7
Leven Kate avg 6
Owen Chris avg 6.6