Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started