CIS 18B ASSIGNMENT 4

AWK


1. Use an awk command to create an output file from the input file. The input file has the scores of one game on each line. For each game, the command prints a line giving the winning team and the number of points scored by the winning team in the game. No game can end in a tie. The winning team can be the first or the second team. After printing all the game winners, the command must also print one line for each team that wins at least one game, giving the name of the team and the total of scores for all their wins. You must use an awk command. The input file is called lab4_1_in. The output file is called lab4_1_out.


lab4_1_in

aaa:23:bbb:34

aaa:44:ccc:12

vvv:44:nnn:40

nnn:8:bbb:14

vvv:12:sss:21

ddd:78:sss:13

nnn:66:vvv:77





2. Use an awk command to create an output file from the input file. The input file contains hyphenated expressions in each field. Each field has exactly one hyphen. The command removes the hyphen and all data following the hyphen from each field. You must use an awk command. The input file is called lab4_2_in. The output file is called lab4_2_out.


Lab4_2_in

AAA-BBB CC-66 DDD-BB

66-23 RR-UU 5-345 AA-B

55-23 234-4 234-12 AAA-B

77-77 88-99 99-1010 6-3





3. Use an awk command to create an output file from the input file. Each record in the input file contains the students names and a variable number of test scores for each student. The output file must contain one record for each student in the following format:

Firstname Lastname : Average_of_Scores

The average_of_scores shows the average of scores for each of the students. You must use an awk command. The input file is called lab4_3_in. The output file is called lab4_3_out.


Lab4_3_in

Blue, George 23 16 34

Red, Jack 34 56 78 90 45

Brown, Mary 23 78 90 98 78 99

Black, Bruce 44 78

Green, Jane 77 77 77 87 88

Gray, Joice 99 90 23 67 78

Purple, Anne 80 30 60 70