Question: In this exercise, you will create a script called if_then_elif.sh that uses an IF THEN ELIF statement and various integer operators The if_then_elif.sh script will
- In this exercise, you will create a script called if_then_elif.sh that uses an IF THEN ELIF statement and various integer operators
- The if_then_elif.sh script will
- Use one command line argument, which will be a number between 1 and 10
- Assign the value of the first argument to a local variable called NUM. HINT: Look at line 5 in the example screenshot for arguments.sh
- Use one IF THEN ELIF statement to compare NUM
- 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 be helpful
- The IF THEN ELIF statement has the form
If [ $NUM operator number ]
then
echo "
elif [ $NUM operator number ]
echo "
else
echo "
fi
- There must be a space after each element to avoid syntax error messages; i.e. there must be a space after the bracket, $NUM, operator and number
- Decide which integer operator to use for each comparison. Look at the slide "Integer Operators"
- Decide what the value of number should be for each comparison
- Decide which message should go where
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
