Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Unix command questions Please help me with these lab questions about Unix/Linux

ID: 3889235 • Letter: U

Question

Unix command questions

Please help me with these lab questions about Unix/Linux command Thank you!

Step 7 - Use the awk command

1.Using the grades.txt file print out the first and last name of each student and calculate/print the grade in percentage that they currently have (assuming equal weights for each assignment).

2.Using the grades.txt file calculate and print the class average for the lab1 assignment

Thank you!

content of grades.txt

FN LN Lab HW1 HW2 HW3 HW4
Ryan Slaven 1 1 0 1 1
Jephthah Eustathios 0 1 0 1 0
Andreas Saša 1 0 1 0 1
Godofredo Gerard 1 1 1 1 1
Edwin Babur 1 0 1 1 1
Ahmad Marin 0 0 0 0 0
Jett Marko 1 1 0 1 1

Explanation / Answer

1.

awk 'NR==1 { print $1,$2, "Averageofmarks" ;next}

NF>2 {sum=0; for (i=3,i<NF,i++);sum=sum+$i;

print $1,$2, (sum/(NF-2)) *100}' grades.txt

Above is the awk command which prints the required output. On this the first line will print the heading row and the next line will print the data in the text file according to the condition.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote