Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.5) Please use the solution to HW 7, problem 2, as a template to write a shell/awk script, myaverage4 , that reads in 4 numbers

4.5) Please use the solution to HW 7, problem 2, as a template to write a shell/awk script, myaverage4, that reads in 4 numbers and then uses a self-defined function to compute the average. The average should be displayed in the main program, not inside the function. Please use the following testing cases to test your script:

$ ./myaverage4 2 7 4 3

The average is 4

$./myaverage4 -2 -1 -4 -5

The average is -3

This is what i have:

#!/usr/bin/

echo $1 $2 $3 $4| awk '

{

print avg($1 $2 $3 $4)

}

function avg (a,b,c,d){

x=0

y=0

x = a + b + c + d

y = x / 4

return y

}'

it doesnt seem to be working.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago