 Okay, today we're going to be looking at running many commands at the same time, but limiting how many are running at the same time. Hope that made sense. If not, hopefully it will become clear momentarily. So here I'm in a folder that is mostly empty except for one file. It is a list of URLs to images on Flickr. So if I wanted to download one of these, I could say wget, and I can paste the URL in here, and I've downloaded it. Great. I'll just remove it for now. Now let's say I wanted to download all of them. I could say cat, that file, I can put it in a while loop. I say while, read, URL. I could do wget, and I can say the URL, done. So what we're saying here is print out this list, read each line of the list, make a loop, and each time it loops, set URL equal to, or the line equal to URL, and then download that URL. I'll hit enter, and it downloads each file one at a time. Which is great. I'm going to kill them. They're small files. They go fast. That would be fine. It's not a long list. But if they were bigger files, or if the list was really long, maybe you want to download a bunch of them at once. Now you probably know that you can do wget, or whatever command, any command you want. Now I'm using wget as an example. This is for any program, so let's say you want to convert a bunch of videos, and you want to do a handful of them at a time. Here we're saying wget download, and then we put this ampersand, and that means run that command, and then continue, and we could say run the next command, which would be a different image. It just ran them both at the same time. Which is fine if you're only doing one or two, I'm going to remove those. But again, if you have really large files, or if you have a really long list, that could become a problem. So let's go back up here to wget, so I'm going to say this list, so I'm saying print out the list, and then do a loop here, and notice I have the ampersand in here now. So that's going to do. You'll see right here when I hit enter, it goes crazy because, oh, it actually crashed my shell. Let's go back into that folder. That didn't happen when I was testing this out. But that's exactly why you don't, one of the reasons you don't want to do this. Back into images, or yeah. So it looks like it downloaded most of them if they didn't get errors. You could actually say file all of these, and yeah, they most say jpegs and they have a size. So let's go ahead and just remove all of these. So there's an example. I had all these processes running at once and it actually crashed my shell. But again, let's say you're doing thousands of these images. Flickr's going to go, whoa, why is this one IP address doing all these requests simultaneously? Or if you're downloading videos, let's say you have a YouTube playlist and you all download a few of the videos at once. You've got 100 videos you want to download. Obviously if you try to download 100 videos at once, it's going to bog down your machine. You'll do three or four at once, but you always want three or four going. Well, that's where the parallel command comes in. So if you don't have installed, say, sudo apt install parallel. And you use apt aptude aptget. Whatever you do on Debian System, whatever package manager you use, I already have an install, but I'll go through this process. There you go, it's already installed. So at this point, what I can do, you can use it two ways. I can cat out my image list, and I can pipe it into parallel. And then I say dash j4 will allow four instances to run at once. So it will start up four if one finishes. It will start up another one if two finishes starts up two. And it will always try to keep four going. And in this case, now the command that you want. I'm going to do wget. You can do dash q. If you don't see the output, I'll say I'll leave the output here. And then these braces is basically saying put here whatever is being piped into here. So if I hit Enter now, so it's downloading four at a time, always, but no more than four, no less than four. So there we go. All those files are downloaded. So I'm going to go ahead and remove all them again. Another way to use it, basically the same thing only instead of catting the list, you could also redirect the list like so, with this. So that does the same thing. You get a message at the top that's just a little message that you can hide if you want. So there you go. Again, I hope you understand what I'm saying here. Again, instead of going through the loop one at a time and downloading them, or trying to download the full list at once, I'm saying always be downloading four at a time. Run this command no less than four at a time. And my example here is very simple downloading files, which is one of the situations where I would use this command, because sometimes I'm bulk downloading stuff from websites. And I don't necessarily want to only have one downloaded time, but I can't download everything simultaneously. Setting a set limit, in this case four, I can speed up my downloads without overtaxing my machine or the server. But another example would be converting images or pictures or doing anything that you have to do in bulk that you want more than one process going at a time. But you don't want to run everything at once. So again, that's the parallel command. I hope you enjoyed this tutorial. I hope you find it useful. Please visit filmsbychrist.com. That's Chris the K. There is a link in the description of this video to my website there. You can search through all my videos and also find a support section to go to patreon.com. forward slash metal x 1000 or through PayPal if you like my videos and would like to support me, you can support me that way. You can't support me financially. Please, please, thumbs up and share this video. The more views I get, it just helps me out so much. So if you could share this video, that would be awesome. I thank you for watching. And as always, I hope that you have a great day.