 Hello, this video is part of a series. Be sure to check out the link in the description of this video, which will bring you to a full playlist of every video in this series, new videos every week at this point. And I'm going to use Vim as my text editor. You can use whatever text editor you feel more comfortable with, Nano, Kate, G-Edit. And I'm going to create a script. I'm going to call it funk.sh. And again, this .sh is more for the user. You don't need that. It's a shebang line, which is the first line in your script that tells the computer what interpreter to use. So here I'm going to say to use the bash interpreter. And what we're going to do today is create a function. Anytime you have a set of commands that you are going to use more than once, and it's not something that's just being used in a loop, but can be called at different places throughout your script. You want to create a function rather than typing out those commands over and over again. And the way you do that is you can type in my fun, that is what I'm going to call my function. You can call it whatever you want. You can call it Bob. You can call it Tom. But I'm just going to call it, I'll just call it funk, short for function. And then you have your parentheses there and then your braces. At this point, anything I put in here is a function that I can call anywhere else in my script by using the funk command because that's my function. So let's say every time I call this, I'm going to clear the screen. I want to echo and I'm just going to make like a header for my script echo and actually I'm just going to put the date command, which should display the date there. So now if I was to save this and make it executable using change mod and the name of the script that's giving this script permission to run as an executable file, I can now use .slash again. That means the current directory, so we're running a script in our current directory, .slash in our script, nothing happens because we never called that function in the script. If I come down here, I can now call this function. I can say funk. And if I save that, I can now run it and you can see that displays the date in a little header there. So what I can do is I can use this more usefully. I can say this, I can say echo, this is text and then I can sleep for two seconds and then I can repeat that funk and I can say echo, this is more text and I can sleep for two seconds and we'll do it at a time, funk, echo, this is the final text, sleep for two seconds. Now I can run this script and we get a little header there and it says this is the text, this is more text, and each time we're getting that header at the top. Now obviously this can be done a lot more efficiently, I'm still repeating a lot of commands, but just to show you the basic, rather than without function, I would have to do something like this. Let's see. You can see that's making my code quite a bit longer, but this will, and if I never call the function anywhere down here, so I can run this now and it behaves as far as the output, the same as before, but I added a lot of lines of code because of repeat stuff. Really I'm repeating a lot of stuff, I'm repeating the echo command and the sleep command, but we'll talk about more of that in the next video where we start looking at passing variables to our function. I thank you for watching this video, I hope that you enjoyed it. I hope that you visit my website, filmsbychrist.com, there should be a link in the description, that's Chris with a K. Also be sure to check out the full playlist, link in the description if you enjoyed this video. Think about becoming a supporter, even dollar a month is very helpful, patreon.com forward slash metalx1000. If you can't be a financial supporter, think about supporting me by liking, sharing, subscribing and commenting on this video. I thank you for watching and as always I hope that you have a great day.