Let's take a look at this repo here that has a couple of different loops in Bash. One of the ways I like to think about a loop is very similar to me going to the grocery store, and picking up a basket, putting some stuff in the basket, and then when I get to the end, and I want to check it out, I got to pull things out of the basket. That's really what a loop is, you're pulling things out of a basket. Let's take a look at this piece of code here. This is the shebang line, this tells the script that it should run in Bash, and then I declare an array. This statement right here says declare dash a array, and this is the name of my array. Then I put inside of the array three items, there's an apple, there's pear, and there's cherry. Now, here I need to do something with it. Again, just like with the grocery store, I want to pull stuff out of the basket, I need to loop, and this is where the four loop comes in. What happens is I say for every item, and this is a loop variable, so it's really a temporary variable, I say, inside of that array, and this is the syntax to pull it out of the array. What I do is I echo what is pulled out. In this case, it'll say that whatever loop I'm on, if I'm on the first loop it'll be apple, if I'm on the second loop, it'll be pair, if I'm on the third loop, it'll be cherry. Let's take a look at this, if I go through here and I run this, and I type in loopy like this, we should see, this apple is delicious, this pear is delicious, this cherry is delicious, and we can actually extend it as well. Just like at the grocery store, you can put more things in your cart, you can put more things in an array. We can go here, and let's pick a strawberry. There we go, and now we've got a fourth fruit here. I wrote it again, there'll be four loops, this apple is delicious, this pear is delicious, this cherry is delicious, the strawberry is delicious. Very straightforward in Bash to use arrays to store things, and then loop through them. These could be for example, files that you want to process or directories you want to search, the sky is the limit. But this is a good example, free to play around with, to get familiar with basic four loops. Now there's another style of loop that I wanted to cover as well, and this is a while loop with a counter. The idea here is that a lot of times you want to count what loop you're on in order to do something, it could be print a line number or show how many things you found, for example, if you were searching for duplicate files in your file system, you may want to do a count of how many times you've found that same file on your file system. That could be a good way to figure out how you're going to do your clean-up. Here's an example. I put a shebang line, here again, user bin in the Bash, I do an echo. How many loops do you want? I then read in from the input from the user the variable loops. Here's where the loop, and the count all goes together. First, I have to initialize a variable. This is a count initialization where I say, I want this to equal one. What happens here is I say well, the count variable is essentially less than the loop, go ahead and continue to do this statement underneath here, and this is really the logic. Again, just like we did in the other example, this count variable will change every time there's a loop, and then what happens here is we increment the count, so this prints out in the first case one, and then the second time we go through what will happen is because it got to the statement, and it incremented it up one. This will go back to the top here, and change this variable, and then this will increment. Every single time we go through here, it'll increment. Let's take a look at how this works, if I go through, and just type in add loop, how many loops do you want? Let's go ahead, and do four, Loop 1, Loop 2, Loop 3, Loop 4. This again is a great way to take a look at what's happening in the script. Let's go ahead, and maybe run 10. There we go, we have 10 loops. Now, if you want to see the action of what happens before and after, we can even do an echo, and we can say, count before increment. Let's just make it very small this time, and let's clear this out, and let's just add two loops. How many loops do you want? We say two, one before increment, Loop 1, two before increment, Loop 2. You can see here that basically the count variable, before we get to the bottom, it's still at one. Once we've gone through, and it prints out this loop statement here, it's now been incremented, and that's why it goes through and shows the next loop. We could also do this, and we can say echo, and we could say count after increment, and we can actually see what happens here, and we can do count after increment. Then you can see it in action. This is always a good way to play around with things, is to go through, tweak the code a little bit, and then see what happens. In this case, we say one before, which is this line, then we loop, that's this line. Then once we do the counter, then you see two after increment, there we go. After it incremented, this next line gets run. You can see really the order of operations when you're doing things. This is really, I think a good thing is to master how a while loop works, and also how to work with count incrementation because this comes up all the time again. How many files did I match or how many times do I want this process to run or try before time is out? There's lots of examples of why using counters to keep track of what you're doing in a loop are really good ideas.