Having trouble devising a script can you please help (Unix sh not Java) Consider
ID: 3735118 • Letter: H
Question
Having trouble devising a script can you please help (Unix sh not Java) Consider the file named data2 as shown below:
Username Score
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.
Explanation / Answer
Following is the shell script:
awk '{ total += $2; count++; total1 = total/count; } {
if ($2 <= total1)
{
print "below Average " $2;
}
else if ($2 >= total1)
{
print "Above Average " $2
}
} END {
print "Average is " total1 }' file1.txt
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.