Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this exercise, you will create a script called if_then_else.sh that uses an IF THEN ELSE statement. The if_then_else.sh script will Use one command line
- In this exercise, you will create a script called if_then_else.sh that uses an IF THEN ELSE statement.
- The if_then_else.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 ELSE statement to compare the value of NUM
- If the number is less than 5, display the message "The number is less than 5"
- If the number is 5 or greater, display the message "The number is 5 or greater"
- When running
- Here are some hints
- Watching the video about IF THEN ELSE/ELIF Statement may be helpful
- The IF THEN ELSE statement has the form
If [ $NUM operator number ]
then
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. Look at the slide "Integer Operators"
- Decide what the value of number should be.
- Decide which message should go where
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