avgs.awk (317B)
1 #!/usr/bin/env -S awk -f 2 3 BEGIN { 4 if (ARGC < 2) { 5 print "usage: avgs.awk grades" 6 exit 1 7 } 8 } 9 10 { 11 sum = cnt = 0; 12 for (i = 4; i <= NF; i++) { 13 sum += $i; 14 cnt++; 15 } 16 print "Student", NR",", $1, $2",", sum / cnt 17 }