Linux - Shell decision making
2K views
Nov 28, 2024
Linux - Shell decision making
View Video Transcript
0:00
Now here I'm going to talk about the decision making
0:03
Now many times in our programs it happens like we can get an unexpected value
0:09
It can be yes or it can be no or I can say it can be true or it can be false
0:13
So based on this particular decision we need to go for an output
0:17
Now a common example I can say I just want you to go for a market
0:21
Now if suppose I am calling my friend to come along with me
0:25
If my friend is coming I'll go along with her. If she's not coming I'll go along with her
0:29
not coming I'll go alone so this is a decision making so the same way it might happen
0:33
into your programs as well like it might you might get a true value or it might get a false
0:39
value so according to the value or according to the result or output which you are going to get
0:44
you need to proceed ahead so accordingly we have to take the decision so that's the decision
0:49
we are going to make into our programs as well now here we can see how we can use this
0:55
decision making as I said we have to go for a correct path
0:58
according to the output we generally got. So any way as for the program
1:04
you need to make the decision as the rule or as the requirement you have
1:10
Now whenever I'm going for a decision making, I have two type of statement which we can use for the decision
1:16
Called us if else statement. Like I have taken example if my friend is coming I go along with her If not means it will come to else if not I go alone so it becomes an if else condition if she coming I go
1:31
with her else I'll go alone so this is called as a if else statement so we can use
1:36
if a statement or if you have multiple conditions so you can go for case is sex
1:42
statement which is just like you can say case statement which we use into this
1:46
so you have multiple case statement which we use into this so you have multiple case is you can go for an option
1:51
Like for example I can take if I want to install an operating system
1:54
I need to select which operating system I do want to install into my laptop
1:58
So I have multiple options. Press A for Windows. Press B for Linux operating system
2:05
Press C for Mac operating systems. So these are the options we have
2:09
So this kind of multiple values if you have, if you have multiple set of variables or set of conditions
2:16
you can go for creating a case. this statement because sometimes it might happen like you know if you're using if else condition
2:23
it will be a huge command or huge program you need to make for you know fulfilling the condition
2:29
or for checking for the complete codes so in spite of that you can create the cases what we
2:35
generally do into these statements so let us check how we generally use this particular statement
2:40
and what are the difference do we have so into next video i'm going to explore more about the
2:45
if else statements
#Programming
#Software