 In our last tutorial, we went over exit codes, which is, you know, viewing whether the last command ran successfully or not. And if you haven't watched that video, I suggest watching it. If you're checking out the playlist, it should be the video right before this. Or you can just go to my website, filmsbychrist.com, that's Chris of the K. There should be a link in the description of this video. And go to the video section and just do a search for exit codes, two words. And it should be one of the videos that comes up. So after you've watched that and you understand how exit codes work, and most exit codes are either zero or one, whether it was successful or not at running, we can then look at the previous command and say, run this next command if the last command executed successfully. So here's an example. We'll say, just like last time, we'll set x equal to cat. So if we echo out the variable x, we get the word cat. Now if we put brackets and we say dollar sign x equals, and then in quotation, cat. And remember to have these spaces where I have spaces because it won't work properly if you don't. It's checking the value of cat right there. It should be true. So we should get an exit code of zero. So if I echo dollar sign question mark, we get an exit code of zero. But let's say we want to display something to the screen if that ends up being true. So I'm going to hit up arrow twice here to go back up to commands that I've typed. So we're checking this. What we're going to do is we're going to say, you might know that if you put an amp or sandale and symbol there, that will throw this command in the background and start running the next command. Well if you do two of them in a row, what that says is run this next command if the last command executed successfully. Which would be an exit code of zero. So I can then say echo x is cat. So if I hit enter here, we get x is cat. But if we go back up and change this to something like dog. So now it's checking right here is x equal to dog? And then saying well if that's true then do this. Well it's not true. So we shouldn't get any output here, which we don't. So what we can do here is this is basically a simplified if then statement in this particular case. We're going to say, you know, if this is true then do this. If it's not true then we're going to do this or so these are two pipe symbols. You may know one pipe symbol takes the output of a command and puts it into another command. Well in this case doing two pipe symbols is kind of like saying or. So if x equals dog, or x equals dog, yeah. Then do this, which it isn't. If it doesn't equal dog then we'll say echo. Well that's not true. And that's what we get in this particular case. Let's look at it again. We know that x equals cat. We set that up here. So x equals cat. Here saying well if x equals dog and it's true then echo this is a cat. So really that's not proper. We probably should change that. Let's say, because that doesn't make sense. Let's say okay in this case if x equals cat then echo x equals cat or x is cat. Otherwise echo well that's not true. In this case if I enter it should say x is cat. So that's what we're checking. Now if we were to change the value of x we say x equals dog in this case. Now x does not no longer equal cat. So when we check does x equal cat well if it does echo x is cat. But since it doesn't what's going to happen is we're going to get echo well that's not true. So since we know right here that x equals dog we know that it doesn't equal cat. So this time when I run the command I should get this output. Well that's not true. So basically it's a quick little one-liner if you're going to do a short little if then statement. This is a quicker way to do it. There's also other ways to use this you know if x it is true. We can a lot of times people if you're running a Debian based system and you have aptitude installed. Although you can do the same thing with apt to get. We can say like something like sudo aptitude update which will update your repository list. And then we can say and n or ampersand ampersand sudo aptitude oops upgrade. So basically what this command is doing sudo we know basically you're running with elevated privileges there. Which you would have to to update and install because you're modifying the actual system. We're saying run aptitude and update the list. Then we're saying well if that was successful. So if you successfully retrieved all list then what we're going to do is we're going to upgrade all packages that need to be upgraded. But see if this was to fail because maybe your internet connection went down or you have you have the wrong servers in your source list pack. It would not try to upgrade because because obviously something's wrong. So that's that's a practical use for this. And then you could you could say or echo it failed. So that would you know if if this was to fail instead of upgrading it would then say it failed. So you know you could also clear the screen I guess and then do that. So anyway that is a quick look at at checking the exit code of something and then continuing if it was successful or doing something else if it was unsuccessful. We're going to use this again in the next tutorial so hopefully you understand it. And I hope you enjoy this tutorial definitely definitely if you like this video if you like these topics give this video a thumbs up to let me know. Comment below if you have comments if you have questions that are technical questions that might take more than a sentence or two to answer. I ask that you don't put the question in the comments because that's a horrible place to have an ongoing conversation. Can't put links in their URLs in there. So a better place would be to go to my site filmsbychrist.com that's Chris the K click on the social network and go down to IRC and check out our IRC channel which is on the free node server. So if you already use an IRC client you can you go to free node and just go to pound filmsbychrist the filmsbychrist channel. Once again Chris is spelled with a K all that information is in the description and it's just a more efficient way of answering technical questions. But if you have comments feel free to leave leave those below try not to be too mean. And once again I thank you for watching and I hope that you have a great day.