Question: Write a bash script that takes 3 arguments. If the second parameter is X, the script will return the multiplication of arguments 1 and 3,

 Write a bash script that takes 3 arguments. If the second

Write a bash script that takes 3 arguments. If the second parameter is "X", the script will return the multiplication of arguments 1 and 3, if the second parameter is "d", the script will return the division of argument 1 by argument 3. The script starts by defining a multiplication function that will multiply the two function parameters and a division function that will divide the function parameter 1 by parameter 2. Both functions will output the result on the screen. The script will exit with a warning message if the number of parameters is less than 3 ! multo { let echo function div { x=$1/$2 $1 divided by $2= ) if [ echo "The script must have 3 parameters" $2 == 'X'] div echo "Unknown command" X-$1$2 fi $x #!/bin/bash $2 == 'd' elif exit 1 $1 $2 mult $1 $3 $1 x $2 = $x done $#-It 3 then echo mult $1 $2 else let $1$3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!