Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- awk '
- BEGIN{
- FS=",";
- printf "%-10s\t%-10s\n", "Name", "Average";
- printf "%-10s\t%-10s\n", "----", "-------";
- test_cnt = 0;
- testTotal[1] = testTotal[2] = testTotal[3] = 0;
- }
- NR > 1{
- name = $1;
- team = $2;
- First_test = $3;
- Second_test = $4;
- Third_test = $5;
- total_sum_test = First_test + Second_test + Third_test;
- average = total_sum_test / 3.0;
- printf "%-10s\t%7.2f\n", name, average;
- teamTotal[team] += total_sum_test;
- teamCnt[team] += 3;
- testTotal[1] += first_test
- testTotal[2] += second_test
- testTotal[3] += third_test
- test_cnt++;
- }
- END{
- printf "%-20s\n", "---------------------------";
- print "Average for Test 1 : ", testTotal[1]/test_cnt;
- print "Average for Test 2 : ", testTotal[2]/test_cnt;
- print "Average for Test 3 : ", testTotal[3]/test_cnt;
- print "----------------------------";
- for (color in teamTotal){
- printf "Average for %s Team: %.2f\n", color, teamTotal[color]/teamCnt[color];
- }
- }' myList.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement