For a mathematical comparison we can use several operands as equal to not equal to greater than or less
than greater than or equal to less than or equal to.
But how to use them in each state run.
Here are some examples.
In the first we are asking if the value of variables is equal to 5 in the second example.
We are comparing.
If the value of variable of our is greater than 7 and on the last example we have two conditions.
We are comparing If our variable Vohra is equal to 5 and variable count not equal to 1 pre-state era
when writing IF statement because there is a need for a space almost everywhere.
So be careful to not omit based next two brackets and around two operand.
I believe that those slides are good as an introduction for a mathematical comparison.
But let's write some script to see it in practice because only writing scripts makes you an expert.
I will create Scribd riginal do multiplication of two numbers inserted as arguments.
Let's name it.
Multiply two numbers not as H.
On the first line as you go shopping Big Bash
now I sign for it.
I will and two variables first.
And second two variables second.
Second equals do not assign to multiplication can be done using that.
So that result equals first Asterix second and now we can print the result using eco common
equal sign.
First step is dollar signs second equals sign.
Result.
Don't forget on basic rule when we are setting variable we don't use dollar sign in front of them.
But when we want to work with the value of that variable we need to prepare and dollar sign.
Now we can save the file
ground execute permission
and around descript and then we can specify some arguments to and fro for example great result is done.
But what happens if we provide only one argument we see some strange output.
Also if you provide more arguments scrip operate only with first two and skidoos it can be confused.
So what to do social is to have logic in our script.
Doudeville exit script when arguments count is different from two.
Does it make sense.
That's right.
Firstly I will write some command so we know exactly what we are going to do.
Exit the script.
There is more or less done exactly two arguments
on the new line.
Right.
If and break it we know that arguments count can be printed using dollar sign hash.
So not assign a hash not equal to or we can negate this if so instead of not equal right equal and right.
Exclamation mark at the beginning.
Also don't forget spaces in that condition.
So if that condition is true what we want to do we can bring some in from my seat as to arguments needed
around a script
with two arguments.
But death is not all.
If we close here if stateman that command would be still executed and a result result variable would
be printed.
We need to exit scribbly here.
So type exit 2 1 and closed the if statement using f i
now we can save the script and see how it looks like when they're running with three months.
We got a message saying around two arguments are great the same is when we use only one argument for
women's.
It is working perfectly but would happen if one argument is some string bought instead of number we
see stretched out.
But we can get rid of it using exit status to make some change in the script
we can display exit status of all that common exit status of previous command can be displayed using
dollar sign.
Question mark.
So just write equal exit so that those
from all command are assigned.
Question mark
now when we ran the script with string as argument we see that exit status is on when we put only two
numbers as arguments and the status is zero.
We can use this knowledge and the right another condition which will ensure that result is printed if
only two numbers are provided to come on.
That means that we will print this out only if exit status equals zero.
So after that line put another statement
if bracket exits that those dollar sign CAUCHON are not equal to zero.
Then we'll print some message equal.
You need to fold
to integer once ran the script again.
And of course we need to exit here.
I can for example choose at those two
after housekeeper.
I have a printing of resolved
so I will just delete the previously decline and pull back the echo line with the result and close the
if statement using.
I
now save the script
and we can write with two arguments.
It works perfectly when we use think in arguments.
Yeah great.
We have message you need to put two integer.
I want that when we see what is exist at those we see number two
when we use Swee arguments the exist that those is one great and of course the script is working perfectly
to multiply five earfuls then this is the most important thing.