Unix HW 4

profilefoooq55
IFT250Lab4B.docx

[Spring 2018]

IFT 250: Shell & Script Programming with Unix

Lab Activity 4B: Scripting Exercises

For the following labs include the following header in your scripts:

# File name: <filename of your script>

# Author: <Include your full name here>

# Term: <Spring 2018>

# Date: <Include the date you created the script>

Be sure to also include detailed comments in each script!

Part I: Formal Formatting

Consider the file named data1 as shown below:

lxiao,[email protected],6705462234,Jackson,NC,764

wnatkin,[email protected],8044344528,Salem,VA,22345

emoe,[email protected],5208534566,Tempe,AZ,85282

mta,[email protected],4345667345,Austin,TX,91030

dcheng,[email protected],5203456789,Matitsi,WY,4587

jfive,[email protected],5206564573,Kyenta, AZ,85483

sadi1,[email protected],6578904566,Wyo,WS,67854

The format is:

UserID,UserID@Email,PhoneNumber,City,State,ZipCode

Write a script named Lab4B.1.sh to print the data in the following tab delimited format:

UserID PhoneNumber State ZipCode

Part II: Group Therapy

Consider the /etc/group file that defines the groups to which users belong.

The format is:

GroupName:Password:GroupID:GroupList

This contains the names of each group on the system as well as the users in each group. Write a script named Lab4B.2.sh that prints the group name and a list of usernames for each group

Part III: An Average Score

Consider the file named data2 as shown below:

pchen72 10

jmaszk 5

bvbui 13

mtcrowle 50

mrchave3 34

This lists usernames and the respective score for each username. Write a script named Lab4B.3.sh that will calculate the average of the scores above and then display the percentage of rows above and below the average.

Part IV: A New Format

Consider the file named data3 as shown below:

XiaoLi,lxiao,[email protected],6705462234,Jackson,NC764

NatkinPook,wnatkin,[email protected],8044344528,Salem,VA22345

EliziMoe,emoe,[email protected],5208534566,Tempe,AZ85282

MaTa,mta,[email protected],4345667345,Austin,TX91030

DianaCheng,dcheng,[email protected],5203456789,Matitsi,WY4587

JacksonFive,jfive,[email protected],5206564573,Kyenta,AZ85483

AdiSrikanthReddy,sadi1,[email protected],6578904566,Wyo,WS67854

The format is:

firstNamelastName,userID@email,phoneNumber,city,state,zipCode

Write a awk script called Lab4B.4.awk that will display the data in the following tab delimited format:

FirstName LastName PhoneNumber UserID@Email State Zip

In addition to this the phone number must be formatted in the following format:

(###)###-####

Part V: The Big Score

Consider the file named data4 as shown below:

pchen72 50 71 55 93 115

jmaszk 45 76 49 88 102

bvbui 59 78 53 96 145

mtcrowle 33 65 39 82 100

mrchave3 54 77 56 98 158

This file is made up by a username followed by five scores. Write a script named Lab4B.5.sh that will compute the final percentage score, out of the max score of 450, for each student as well as the class average overall.

Page | 3