Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please take a screenshot of each command for all the questions Please for the questions 1-6. 1. Expression evaluation - you can evaluate arithmetic, relational

please take a screenshot of each command for all the questions Please for the questions 1-6. image text in transcribedimage text in transcribed

1. Expression evaluation - you can evaluate arithmetic, relational or logical expressions in script by encapsulating in double parentheses (O). If you need to assign value to a variable, prepend with $. Example: sum=$(($1+$2)) Create a script that accepts two numbers in arguments, calculates the sum and displays output following format: Sum of and is sum 2. Conditional statement if/else/fi statement is decision making structure to control the flow of execution. Example: if ($1 >$2) echo "First value is bigger" else echo "Second value is bigger" Create a script that accepts two numbers in arguments and does comparisons using above example. There is an expanded form available for multiple comparisons. It uses if/elsif/else/fi. Example: if ($1 = $2) echo Both values are equal" elsif ($1 >$2) echo "First value is bigger" else echo "Second value is bigger" Modify your script that incorporates above example. 3. Conditional statement -case/esac is another decision making structure to control flow. It is more efficient and flexible. Example: case $1 in 1) echo "One" 2) echo "Two" 3) echo "Three" *) echo "Unknown" esac Note: An * in last option works as a wildcard will be executed if none other matches. Create a script that uses above example to display number passed as argument as text. 4. Loop statement for loop allows to repeat a set of commands for every item in a given list. Example: for i in {1..5} do echo "Iteration no: $i" done Create a script that incorporates above example. 5. Loop statement - while loop is another control flow structure that allows a set commands to be executed repeatedly based on a given condition. Example: i=1 while [ $i -le 5 ] do echo "Iteration no: $i" i=$(( $i + 1)) done Note: the relational expression is encapsulated in square brackets. It requires an extra space both after [ and before ]. Create a script that incorporates above example

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

Describe effectiveness of reading at night?

Answered: 1 week ago

Question

find all matrices A (a) A = 13 (b) A + A = 213

Answered: 1 week ago