(Solved) : Exercise Create Script Called Ifthenelifsh Uses Elif Statement Various Integer Operators I Q44109276 . . .
- In this exercise, you will create a script calledif_then_elif.sh that uses an IF THENELIF statement and various integer operators
- The if_then_elif.sh script will
- Use one command line argument, which will be a number between 1and 10
- Assign the value of the first argument to a local variablecalled NUM. HINT: Look at line 5 in the examplescreenshot for arguments.sh
- Use one IF THEN ELIF statement to compareNUM
- If the value of NUM is less than 4, display the message”The number is less than 4“
- If the value of NUM is between 4 and 7, display the message”The number is between 4 and 7“
- If the number is greater than 7, display the message”The number is greater than 7“
- Here are some hints
- Watching the video about IF THEN ELSE/ELIF Statement may behelpful
- The IF THEN ELIF statement has the form
If [ $NUM operator number ]
then
echo “<message>”
elif [ $NUM operator number ]
echo “<message>”
else
echo “<message>”
fi
- There must be a space after each element toavoid syntax error messages; i.e. there must be aspace after the bracket, $NUM,operator and number
- Decide which integer operator to use for eachcomparison. Look at the slide “IntegerOperators“
- Decide what the value of number should be foreach comparison
- Decide which message should go where
Expert Answer
Answer to In this exercise, you will create a script called if_then_elif.sh that uses an IF THEN ELIF statement and various integ…
OR