 Today, we are going to do some practical shell scripting. What do I mean by that? Most of my tutorials, I try to show you how tools work and things you can do with it, but people go, well, how do I use that in the real world with scripts I'm writing? And the answer is, I don't know, because I don't know what you're trying to do. Programming is problem solving. You have an issue, usually something you want to automate and you want to script it out and you need to figure out how to do that. And so I show you these little bits and pieces that you should put together, but I figure why not just make up a scenario and we'll try to write out a shell script that does this. And what we're going to do is we're going to grab the titles in this video of a YouTube video based on the URL, okay? Now I'm aware that there's a program out there that does lots of stuff about getting information on other things from YouTube. I'm not even going to say the name of it because any time I mention it in a video, I get a strike on my channel, but we're going to do it manually, okay? So here I am at filmsbychrist.com. That's Chris Decay. There is a link in the description. My website, you can search through all my videos here and I'm just going to choose one here. I'm going to click on this one here. I'm going to pause the video once it starts up, blah, blah, blah, wait for it to load, okay? Pause that. Okay, I'm going to grab the URL from this channel. And I am going to use WGet, but you can use girl. So I'm going to say, you know, WGet. Now if I just do that, it's going to download the HTML from that page to a file, but I don't want to do that. I'm going to say dash queue for quiet so I don't see the progress or information about the download. And I'm going to say dash, or not dash, I'm going to say dash queue and then a capital O. That's the letter O, not a zero dash. I was going to just dump the output to the current screen. Ha ha, that's a lot of stuff. Now, what I'm going to do is, you know, go through all that. Now we know the title of this video is tutorial compilation, okay? It's part of the name. So what I can do in here is I can take that same command and then pipe it into grep. By the way, this is an intermediate video. I kind of assume that you know how these basic tools work, but hopefully if not, you'll learn something. But grep is just going to say, hey, in all that output, look for these words. So I'm going to do that. The thing is, a lot of stuff is all on one line. So I get a lot of blah, blah, blah here. So what I'm going to do is, before I do the grepping, I am going to pipe it into a TR. You can also use said. I'm going to say find all the commas and make them new line characters and then find the line that says tutorial compilation. Okay, that helps a little bit there. So we're looking through here and there's one right there and we have one right here. So we have this one that says title, title, and there we go. There's our title right there. That's one option. So let's see if we can find that. So we can see this line starts with title inside quotations, colon, and then quotation mark. This other line starts the same thing but doesn't have that quotation mark there. So let's try grepping for that. So we'll erase this and try to put this on a line so you can see it like so. So I use single quotes because there's regular quotes in there. When I do that and lo and behold, we do get a bunch of stuff returned and it looks like the first one here is the title of this video and then there's other words that have title. Oh, you know what I didn't do? So this finding all instances of that. What I want to do is right here add the little carrot symbol and that's going to say lines that start with quotation marks title, quotation marks, colon, quotation mark. And there we go. We have our title. Let's go ahead and use the cut command and say, okay, look at the quotation marks and give us the fourth column. We have the title of the video. Now we need to make sure that this works against other videos. So let's go back to my films like Chris. I'm going to copy the URL from this video and I'm going to replace the URL here with the URL video there and we'll run that. And it says, build do nuke gum 3D on Linux and that was the name of that video. Let's grab another one. We're going to copy the link address and in here we will replace it. Once we've tested on a few, we will then throw this into a script. There we go. So this seems to work. This right now will get us to the, you were scraping it. So as long as they don't change the format of the page, which they could do at any point, this should work. So let's go ahead and just highlight that and let's start making a script. I'm going to use, well actually I'm using Neo Vim but I have an alias to Vim but I'm going to be using a Vim variant to write my script and I'll just call it YouTube titles.sh. Okay. And I'm going to say bin bash here at the top. This is saying this is a bash script and I will paste in that right there and I will save it and exit and I will say make that executable and I'll say this and voila. It gives us the title of that video. But of course, that just gives us the title of the one video. Let's go in here and what we're going to do is I will delete in these tags and I will say dollar sign URL and I'm going to say URL equals our first argument. So now I can say YouTube titles and I can copy one of these videos. So let's go ahead and copy this URL and I will paste that in there and it gives us the title of that video perfect. But what if you don't give it anything, right? We're probably going to either get an error or no output, no output. So we should do some checks, okay? So what I'm going to say is I'm going to say, okay, dollar sign one. Okay. If that does exist, I'm going to say the variable URL equals that first argument. If it does not, I can say read-p please enter video URL and I will say URL. So what's saying here is, okay, check. If there's an argument, then make the variable URL equals that argument. If not, ask for the URL. So now we'll save that. We'll run this. I didn't give it a URL. So I will copy one from here. Copy link, paste it in there. Great. And of course, if I do give it a URL, let's give it a different URL. Copy. It shouldn't ask for it because it sees you gave it one. But what if you give it a URL that isn't a YouTube URL? So, and also, what if you just want to use what's in the clipboard? I like doing that a lot. I like having, you know, checking for user input. If there's no input, check the clipboard. If there's nothing in the clipboard or not the right thing in the clipboard, then ask for it. So let's go back in here and see if we can write this a little differently. So if URL, if the first argument exists, where you're going to, say, set the URL variable to that argument, then I'm gonna say, if that fails, then I'm gonna say URL, whoops. Put that on the new line. I'm gonna say URL equals. And for me, I like using XClip. Now, this may not be, you know, when you're sharing a script with somebody, you have to either make a package manager or have your script check. I'm using XClip, which is not installed by default on all systems, but should be in the repositories. So right here, I'm not gonna go into too depth with this script, but you would want to do a check to see if XClip exists. And if not, then there's a, was it X, S, X select or X, S, E, L? I don't know, I don't use it. There are different ways to get stuff from the clipboard. And if you're on termux, you can use termux dash clipboard or something like that. Okay, so here we're going to say that. And then, so we're looking for an argument, saying the URL to that. If that, if we don't pass an argument, we're gonna check the clipboard. Next, we're gonna say, okay, dollar sign one, if it does not equal, HTTPS colon forward slash forward slash Y, and anything past that. I think this is the proper way to write this. Okay, so if it does not, then we are going to say to ask for a URL, okay? So we're here, we're either getting it from the user input. We are checking the clipboard if that doesn't exist. And then we're saying, okay, now that we have a URL, is it actually a URL that at least starts with why? Because I say why because here we're using youtube.com, but if you actually select the share link, it's actually shorter. So share here, it's going to be, I guess I could go U because it's U-T-U dot B-E. So let's do that, let's just go. So as long as it starts with U, okay? So let's go ahead and we'll copy something that is not, and I will run my script here and I will not pass it an argument. And it should ask me for a URL, yes. So now I can copy this URL, paste it in there, and I got the title. Now, if I was to run it and I was to copy this one, let's see, websites as Android apps, copy that, we will paste it in here. Oh, nope, I did something wrong because it should. Oh, WWW, see, we could have a check multiple variants. I'm just gonna leave it as, make sure it's a URL, okay? Okay, so that time it looked at this, it saw that I pasted something and it has HTTPS. Now, if I was to do this, it's gonna ask me for it because it doesn't start with HTTPS. And then finally I could go copy this URL and not pass it anything, but it should see. See, it didn't work. Let's see, xclip-o, okay, it should have worked. I typed something wrong. This is part of the learning process. Okay, we're saying, okay, is there an argument? If so, set that to that. And then here we're saying URL equals this, and then we're saying, okay, oh, that's the problem. This should be URL because we've set the URL. Okay, now let's run it and it should check my clipboard. Let's make sure I have a URL selected. There we go, I'm gonna check my clipboard. So, we have those three different options. You can pass it an argument. If you don't pass an argument, we'll check your clipboard. If your clipboard matches, at least HTTPS, it will use that. If neither of those things work, it will ask for a URL. And then it will give you the title. So, that, I think, is pretty good. We have three lines of code and a pretty good, I think, script here. So now we can use it, however. So, I hope you found this useful. I hope you learned something. So again, this is kind of an intermediate immediate video which I mentioned a few minutes in the video. I should have said right off the bat. So hopefully you understand some of this, but yeah, here we're just checking. Are we passing something? If so, use that. If not, check the clipboard. So again, XClip, XClip can put stuff in the clipboard or show you what's in the clipboard. So as I showed you, if we do XClip-lowercase, oh, it shows you what's in your clipboard currently. And then here, we're checking. Okay, if it's not a URL, then ask for a URL. And then we will continue. Oh, you know what we should actually do is, again, check. Does URL have HTTPS in it? If not, then we should exit. And you can exit one with an error if you wanna count that as an error. So now, if I run our script, right, it's gonna ask for something. And if I give it something that's not a URL or just gibberish like this, it will exit. You could set it up to give a message or something, but it's just kind of canceling out, right? So yeah, that would be the last part for that. So now we have four lines of code. And I think that this could be pretty useful, if not just for getting the titles of YouTube videos, but if you're scraping websites, these four lines could be in your script all the time for making sure that a URL is passed in some way, right? So I thank you for watching. Filmsbychrist.com, that's Chris the K. There's a link in the description. As always, I thank you for watching. Please visit my website, my Patreon page. Think about supporting the support section on my website. There's links to everything in the description of the video. And as always, have a great day. Today, we're gonna be talking about running Linux completely from RAM. What do I mean by that? So when you're running a live distro of Linux, either off a USB flash drive, a CD or a DVD, or even an image off hard drive, that thing is running in RAM. That thing, that distro is running in RAM, but it's pulling information off that disk, whether it's the CD or flash drive. So everything's loaded to RAM as you use it, but as you're requesting files off the distribution, it's coming from the disk, which nowadays, you know, off a flash drive, especially reading at least is fairly fast, but especially back in the day when it came to CDs and DVDs, it could be fairly slow. So if you go out the whole thing to RAM, it's faster. Also a benefit of running everything out of RAM is normally when you boot off a USB flash drive or CD, you gotta leave that disk in the computer. Well, if you boot everything to RAM, you can take the USB flash drive or CD out and the whole thing will still run. You don't need that drive in there anymore, which is nice. So we have speed as a benefit. We have the benefit of not having the disk in the system, but also if you're really paranoid, you can have a diskless system where you just have the RAM. So normally when you're running off a USB flash drive, lots of times it's a read-only image so nothing's being written to the disk unless you set up some sort of persistent mode. But if you really wanna make sure that nothing is being saved to that drive, having no drives in the computer is nice. Everything's written to RAM. So as soon as you turn off the computer, you know that everything's going to be cleared out. So what are the downsides to booting to RAM? Well, one, longer boot time because you gotta wait for the entire image to be copied to RAM. So if you have a distro that's a gig or two gigs, depending on the speed of the flash drive in your computer, it might add 30 seconds a minute or even two minutes to the boot time as it loads everything to RAM. Another downside is if you're limited on RAM, you're now using up a lot more of your RAM as disk space. So let's say you have four gigs of RAM and you have a distribution that the image is two gigs. Well, you just used half of your RAM just to load up your system. Now you're only running with two gigs worth of RAM, which especially if you're downloading stuff could fill up fairly quickly. Because remember, you're not using a hard drive, you're running from RAM. So that's a downside, especially, you know, working with older machines. Now some distributions automatically boot to RAM, especially lightweight distributions. I believe Puppy Linux does, DSL does, that's darn small Linux, we'll say that. Another one is Slitaz Linux. How do you pronounce Slitaz? How to pronounce dot com. Slitaz. Slitaz? Slitaz. Slitaz? That doesn't sound right. Ooh, how to pronounce dot com forward slash French. I think it's a French distro. Slitaz. Slitaz. Slitaz. Slitaz. Slitaz. Slitaz. Slitaz. Slitaz. Ooh, the official forums for Slitaz. How to say Slitaz? Slitaz is an acronym. It is, I have no clue. For simple, lightweight, incredible, temporary, autonomous zone. Is that really what it stands for? I had no clue. Here's another answer. How to say Slitaz? You don't say it. Yeah, use it. Some other distributions, such as MX Linux, when you boot up, if you go into advanced options, there's an option to boot from RAM. Greml Linux, I don't know how you say it. G-R-M-L Linux also has an option in the menu, but not all distributions have the option to boot to RAM in a selectable option. So today we're gonna look at how to boot those distributions from RAM. Now, I mainly stick with Debian distributions. I'm not sure how this works with other distributions, but basically we're just going to pass a flag to the kernel to say boot everything from RAM. And it's super simple. We're gonna do it with a few different distributions. So let's go ahead and have a quick look. Okay, we're gonna start out with Greml Linux. Again, this is one of those distributions that does give you the option. If we go to boot options, we can choose that and we can go down to load to RAM. So it's gonna start the boot process and here in a moment you'll see that right here it's copying over the file system, 43%, 68%, 100%. So at this point, if I was running on a physical machine, I could unplug the USB flash drive or eject the CD. This distribution is the smaller version. It's only about a half a gig. And again, I'm running in a virtual machine. So it copied over fairly quickly, but again, the speed of it copying to your RAM will depend on your machine and your flash drive. But it does add to the boot time, but now everything is running completely from RAM. And I just had to choose that selection from the menu. So here we're working with MX Linux and at the bottom here you'll see F4 gives you options. If I hit F4, you can see that there is an option to RAM. When I click that and then I start booting, it will now load to RAM. And again, this is a bigger distribution. So it will take a little bit longer to copy to RAM, about two gigs. Again, I'm working in a virtual machine so it's going pretty quickly, but once this little process here is done, in real life, if I was working with physical hardware, I could unplug a USB flash drive or a CD-ROM. So again, here's another distribution that gives you that option in the boot options where you can just select. So moving on to distributions that don't give you the options in the menu. Here we are with Ubuntu. So I'm booting Ubuntu or however you say it. And you can see we have try or install. Now, you'll notice right here, we have the option E to edit. So I'm gonna hit E and here we have our boot options. And right down here where it says Linux, this is your Linux kernel and these are the options you're passing to it. All you have to do is somewhere in this line, we're gonna write to RAM, all one word just like that. And that's all you have to do and then you can hit F10 to continue. But I'm gonna erase where it says splash and quiet so we can see what's going on. Otherwise, you don't see, it just gives you the little process that it's booting but it doesn't show you everything. I'm gonna go ahead and hit F10 now. And you'll see in a moment, it will say copying to RAM or it's gonna be mounting some RAM. So yeah, copying live media to RAM and it shows you the command it's running. It doesn't give you a nice progress bar like the other distributions do. But once this is done copying to RAM, we'll have a system loaded to RAM. So here we are with a Debian live distribution. Now there is an advanced options here but there's no option to boot to RAM. So we'll go back and we'll go up to the default option here. Now in some distributions you hit E but you look right here, it says right at the bottom of the screen, tab to edit the menu entry. So we'll hit tab and it gives us the menu option here. You see Linux is giving us the kernel. And again, all you have to do is hit space to RAM and I can go ahead at this point and hit enter to continue. Now it does have the quiet splash screen. So if I hit that, it's going to show a splash screen again just like Ubuntu would. But you can hit delete on the keyboard and it will show you what's going on. And here we go, it's copying the file system to RAM. It does give you a percentage bar unlike Ubuntu. I don't know why Ubuntu doesn't. I guess it's just Ubuntu. But here we go, we can see 71%, 80%, 93%. And now we are copied to RAM. And again, I could remove that disk if I was booting to actual hardware. So you can see just adding to the kernel options that to RAM option will allow you to boot to RAM. Let's try another distribution. Here we are now with Linux Mint. Again, read what it says on the screen. But as you can see, in this case, we're going to hit E to edit. And just like on Ubuntu, we'll go down to the line with Linux, we'll go to the end and just in here, whoops, we'll type to RAM. Again, you can remove the quiet and splash so you don't get the splash screen. But if you accidentally continue, which in this case, you can hit control X or F10, just read what it says on the screen and it will tell you what to do. I'll go ahead and hit F10. It will start to boot if the splash screen comes up and I want to see what's going on. All I have to do is hit, there's different keys, but I'll hit delete. And here, just like Ubuntu, since this distribution of Linux Mint is based on Ubuntu, it's not going to give you a percentage on how much it's copied, but you can see here that it is mounting some RAM, a temp file system, and then it will load to RAM. And now you're running from RAM. So there you have it. Now you can boot your distributions of Linux completely to RAM with no hard disks whatsoever, including the drive that contained the original file system. Now, some distributions, again, do it automatically, usually smaller distributions. Some will give you the options menu, but now, even if they don't give you the option in the menu, you know how to get it to boot to RAM, at least again, on Debian-based systems. I would assume this would be the same on other distributions of Linux that aren't Debian-based since this is a kernel flag and we're just passing this information to the kernel, but I haven't tested it out on arch-based distributions or Fedora or anything like that. But give it a try, let me know in the comments if you try it on one of these other distributions and let me know if it works or doesn't work. So I thank you for watching. Again, my website is filmsbychrist.com. I'm Chris, that's Chris with a K. Link in the description. I also have a Patreon page to support me through LibrePay, PayPal. I thank you for watching, liking, sharing, subscribing, commenting, all that good stuff. And as always, I hope that you have a great day. Okay, here's something that I came across today. My wife wanted to get a copy of this little crochet instructions for creating these crocheted bears. Now we created an account and we logged in. It was free to create an account and log in and we can see all the instructions. My wife can just follow along on this webpage. But let's say we wanted to print this or have a PDF that we could save. Now, you might go, Chris, there's a button right on the screen that says download PDF. There's also one up at the top of the page here that says download PDF. But if you click on that, it actually just brings you to a website where they try to sell you stuff. We just want to be able to print or have a PDF of this page. And so you go, okay, control P to print and I'll save to PDF. Let me click on the page, control P and then print to PDF, but you'll notice in the preview here that all the instructions and images are missing. It won't let you print them. That's not an issue. This is just a CSS option. And since this is HTML with CSS in a web browser, we can modify that. So we're gonna open up a developers tab in a Chromium-based browser, Chrome Brave, which is what I'm in, Chromium or Chrome. It's gonna be F12. I think it's a little bit different in Firefox. I don't remember the keys, but F12 in most browsers will open up the developer console. We can click over here where it says elements. So make sure you're in elements and it shows you all the elements of the page. Within here, we're gonna click, we're gonna hit control F to search and I'm just gonna type in print. And you'll see the first thing on the page and depending on the web page, it may not be the first one that comes up, but we have, okay, media print. This is what we're gonna do when we're printing for any item that has, in this case, class of inside article or legal notice. You'll see that inside article, it's set to none and the legal notice is set to inline. So it displays that when you go to print instead of the actual instructions. So what do we do? How do we get this so that we can view it when printing? Well, we're just gonna right click this CSS here and click delete for that element. And it might, again, be slightly different on different pages, but you gotta look for something like that in CSS, some print, a media print option. And then we click back on the page and now if I hit control P, now that we've removed those instructions to hide the article from printable view, it takes a moment because it's loading up more stuff but now you can see I can print or save the PDF for this page. And that's it. Again, it's gonna be slightly different on each page but you're gonna look for that media print option within CSS in most cases. And if you just remove it or modify it, you'll be able to print what you wanna print. So thanks for watching, filmsbychrist.com. Hope you found this useful. And as always, I hope that you have a great day. Hello and welcome to filmsbychrist.com. Today we're gonna be converting a whole bunch of stuff into JSON format. I love JSON format. I think it looks nice, it's clean and it's easy to parse through and is widely used. And we're gonna convert a whole bunch of stuff to JSON using a program called JC. If you are on a Debian-based system and I'm assuming most other distributions, you should be able to find it. I'm going to also grep for JSON otherwise there's a lot of programs with the letters JC in it. But here we go. You can see JC is a JSON command line output utility. A viewer told me about this a while ago and I've been meaning to do a video on it. I wish I wrote down the viewer's name so I can give them credit. It is a great little program. So sudo apt install JC on a Debian-based system. Check your package manager for whatever distribution you use. But here's an example. I have a CSV file. CSV file is a comma separated file. So let me go ahead and just open that up with my spreadsheet editor here. And you can see in this particular case the top column is the name of what each, the top row is the name of each column. So we have gender, a name title, name first, name last, email address, yeah, you know, login, UUID. So we have all that information. So that's how it knows when it converts to JSON what to name each element of it. So let's go ahead and discard that. And now instead of looking at it like so, and yeah, I could go through that. I could grep for stuff and then cut at the commas. But it could become confusing if some of the entries like this right here have commas. Then it's wrapped around parentheses and then I have to figure out how to determine which comma is a comma that's a delimiter and which one is just part of the string. It's a lot easier if I just convert JSON because then I can use something like JQ which I've talked about many times in the past to parse through it. So all I have to do is cat out that file but pipe it into JC. We're gonna tell JC that this is a CSV file. Boom, and it converts it to JSON. Now that's just all on one row. I can say dash dash pretty and it will make it pretty. But you can also shorten that up to just dash P. So again, we're catting out that file into JC dash CSV to tell it that it's CSV file dash P for pretty. And we have that and then we can again pipe that into JQ to find what we're looking for. Or even at that point, that's times it's just getting to that point. You can now grep or said through it fairly easily but JQ would be a better option if it's available. Another option and I'm going through this. JC supports so many different things. Their website, most of what I'm about to show you are just examples from their website but also link to my show notes in the description of this video. If I use PSAUX, I can list running processes on my machine. And again, I could grep through that and try to awk through the different columns but sometimes they're just spaces in the program names that can throw you off. Well again, I can just use that same command, pipe it into JC dash P for pretty and then dash dash PSSA that this is process output and it converts it to JSON. I can find what user started the process, the process ID, is it a TTY when it started, what the command is, all the good stuff. Now you can also, the date command's pretty simple and you can get, the date command has built in things. If I just wanna get the day or the week or the month or the day of the week or the year, I can get all that but you could also, if you wanna in JSON format, maybe you're gonna be using it in another application or the programming language and it's just easier to have it in JSON. Well, we have to tell it what our date format is and then the date command and you can also export this as a variable and then I'll pipe that into JC, date, date and you can do prettier dash P and there we go, we have all this information but now nicely labeled so I can get that specific piece of information. Again, date kinda has that built in so how about I wanted to show you that, that was an example on their website. How about the dig command? The dig command, we run that, give it a domain and it will give you information regarding that server. Well, we can also just say JC dash dash pretty or again dash P, dig in that and now it gives you that same input but it's now converted it to a nice JSON format. Clean, easy to read, how about ARP? ARP's gonna list machines that are currently on my network, right? Well, let's get that in JSON format. Pipe that in JC dash P for pretty, dash dash ARP, so tell it it's ARP output and now I have it in JSON format. It's gonna be great like if you're running stuff on a server and you wanna output it as some HTML you can use some JavaScript to go through it a lot easier this way. How about the if command, right? I can do if command, if config to get information about my network and of course we can pipe that into JC as well and get information like that and of course we could always pipe that into JQ and say, hey, look for this device and then get me the IP address and that's one way to get your IP address. You know, I can use that with grep and awk and it's a little bit shorter but it's not as accurate because you might have more than one wireless device and just have it in JSON format can be useful. How about the list command? Let's list stuff that's in my USR bin, right? All the files in there, long list. Well, let's run that again. Again, we'll use JC and we'll tell it that we wanna make it pretty and that this command is from LS, it's LS output and we get all that information in JSON output. You're getting the idea here, right? How about we're gonna ping something? Let's go ahead and ping 8.8.8.8.8.8. How many times did I say it? And we'll say three times. So it's gonna take a second, it's gonna ping that three times but then JC is gonna give us the replies and the delays and all that in nice JSON output. Uptime, uptime, simple enough, this is my uptime and we can tell it, you know, give me that in JSON. Again, a lot of this, you could probably use awk to cut through this but having in JSON format just standardizes it for different languages and applications. And last example, we're going to use it to convert some XML, which is one of the main reasons I would use this because a lot of things still use XML. I'm not a big fan of XML compared to JSON. I feel like JSON is cleaner, easier to parse through. In my opinion, I'm just probably more used to it but I feel like XML just has way more characters than need because it has open and closing tags instead of like, this is the name and everything between the curly brackets is what you want. So here's an example of some XML. We can run the same command but then pipe it into JC, make it pretty, XML. And now we have that same information in JSON format. That is it. I thank you for watching once again, filmsbychrist.com. That's Chris with a K. There's a link in the description. I have a Patreon page. If you like my videos, if you find them useful, think about supporting there. Also have PayPal and LibrePay on my website, filmsbychrist.com. All there's links to all that on my website and in the description of the video. I do thank you for watching. I thank you for your support. Those who are financially supporting me and those who are not financially supporting me, I thank you for subscribing, liking, sharing and commenting. I hope that you have a great day. So you wanna make a video game, you wanna have cool eight-bit sound effects and of course you could go to a website where they have tons of free sound effects that you can search through and they may have licenses that are available for whatever project you're working on but why when you can make your own? Let's go ahead and do that. So you're gonna wanna use whatever package manager you have for your distribution and you wanna search for SFXR. In my case on Debian, I'm gonna install SFXR-QT. I'm gonna be using app. So I'm gonna suit app that. Once it's installed, we're gonna run it. SFXR-QT at the shell or find it in your app menu. This is what the interface looks like. It's super simple. So up here on the left, you have generators, pickups or coins, lasers, shooters, explosions, power-ups. All these things have similar attributes. So clicking these will set presets that generate a random sound but with those attributes. So for example, I can click this and I get a coin. Let me turn my volume up here. So each time I do it, it's a different sound but it's that similar sound of a coin or pickup. You're collecting something. You can get lasers and explosions, getting hit or hurt and of course, jump sounds. And you'll notice over here on the left, you have sounds as you generate them, as you're going through and you click on these. If you hear when you like but you've already clicked on the button again, you can see the previous ones here on the left. So you can go back to a previous one by clicking on it here. And once you've found one, you can also use tools. You can play the sound again down here. And on the left, you can mutate that. So it's gonna take that sound but just tweak it a little bit. So you can modify it. And of course, you can adjust all the settings by yourself here in the middle. And of course, you can save that as a wave file. You did it. You created your own sound effects with a simple little simplifier, simplifier synthesizer here. And yeah, that's it. Thanks for watching. Hello and welcome to a video from filmsbychrist.com. I am Chris, that's Chris with the K. There's a link in the description to my website. Today we're gonna be talking about archives, tar archives. So we're gonna be working with tar, what is tar tar stands for? Tar archive or tar tape archive. And so back in the day, storage was really expensive. And one of the ways we would store stuff is on tape. And so we would use tar to put files on a tape. We still use that program but we're saving to files rather than physical tapes. And it will allow us to take a directory and basically put all the files into one file. Let's go ahead and do that as an example here. So what I'm gonna do here is I'm gonna say tar dash C for create, V for verbose. That will list the files out as they're being compressed. If you don't need that in there, if you want it to be quiet as it's compressing, I kind of like seeing the files listed as they go in. And then dash F for the file name. Then the name of the file. So in this case I'm just gonna call it projects.tar. And I'm giving it a directory. USR local bin, which is where I keep all my scripts for my system. And I will go ahead and run that. And you can see it lists out all the files because we had that V option in there. If I list out what's in our current directory, you can see we have the tar archive. If I show a little more information on that, you can see that it is 208 megabytes. There is no compression going on here. This is just the files all put into one file. Now to extract those, it's super simple you say tar dash X for extract F and then the project or the file name in this case projects.tar. And you can do that. It's going to uncompress them all. We list it out. You can see or not uncompress it, but extract them all. And you can see there's a, it extracts the directory. So USR local bin. And you can see all the files in there. I'm gonna go ahead and I'm going to remove that directory we just created. And we still have our tape archive here. What I'm gonna do now is, I'm gonna say tar dash C for create Z for zip. Cause again, the first thing we did was just put all the files into one file, but there was no compression going on. To compress, we're going to use GZ or GZIP. And we can do that right within the tar command. And I'm going to say again, V for verbose. You don't need that, but that will list the files as they're being compressed dash F and our project file name. So this time I'm going to say project.tar.gz. And I'll give it that same directory as before. USR local bin. Now again, so GZIP can compress a file, but it can compress a directory to the best of my direct, my knowledge, where tar will take a directory or a group of files and put them into one file. So basically you're creating one file that's all the files put together and then you're compressing it. You can see it's taking a little bit longer. When we did the first command, we didn't compress it. It took like a second. That took maybe five seconds. But if we were to list out all our files now, you can see that our compressed archive is less than half the size of original archive. So we're compressing it, slows things a little bit down when you're compressing it or extracting it, but makes a file size a lot smaller. And you can give it options as to how much it compresses it and that will slow things down but make a smaller file in some cases. It can press pretty good here because most of the files in that directory are scripts, which means they're plain text, which means they compress very well. There are a couple of binary things in there that aren't gonna compress so well because, well, they're binary files that are probably already compressed to some point. Okay, so we've created a tar archive. We create a tar archive that's been compressed with GZIP. We've extracted it. Let's go ahead and see. Let's say you have an archive file and you want to see what's in that. You wanna list the files. We'll use tar-t. T, I'm not really sure what t stands for. Maybe table of contents. But it will list out what file's in there. I'm gonna say verbose f for file. I'll give it the file name and I'll give it the tar GZ file. And there you go, it's listing out all the files and information about them to the screen. So I didn't need to extract anything. So that's great, but let's say I'm looking for a specific file so I could do something. I could run that command. Of course, I can put it in grep and I can say something like YouTube play. And you can see any file that has YT play in it will show up. But we don't need to pipe it into another command. Now, if I wanted to look for this file here, I could actually just after within our tar command here, I can just in quotation marks, put the name of that file and it will list out. Oh, yep, it's in there. The thing is, writing it like that, you need to know the full name and path. If I just said YT play, it's not going to find that. It's gonna say it's not in the archive. But what you could do is you could do something like dash dash wild card cards with an S. And if I do that, might need to put asterisks around there. There we go. Now it's listing everything with YT play in there. And it's doing it without having to put it into grep. So that's how you would do that. You would search through using wild cards and use your little asterisks here. Otherwise you need to give it the full file name. That way you can look through what files are in there. And once you know what files are in there, you can find the file you want. And instead of extracting them all, you could extract just one. So again, I just wanna make sure. Okay, I already deleted the USR folder. So I'm gonna say now, I'm gonna say tar dash z x v y. And then I'm gonna give it the archive name. And then I'm gonna give it the file name that I want to extract. But again, I gotta give it the full name. So actually let me go ahead and do this again. And let's say I want to extract this file here. So what I would do is I would say tar dash z x v f in our project file name, and then the full path to the file we want within the archive. Okay, so we're gonna run that and it's extracting just that one file. If I list out now, you can see we have that USR directory and I can look inside that directory and it's just that file. Now again, if I wanna extract multiple files that are matched, I could do something like this. I could say dash dash wildcards. And I can say, whoops, let's try that again. I have a bunch of scripts with YT in it. Those are my YouTube scripts. So I just go ahead and do that and you can see it's extracting all of those, but just those ones with that match. So if I was to list out what's in there now, it's extracted all those files. Now, I hope you found this video useful. I will put a link in the description to all the notes of everything I just did so you can look at those, copy and paste them, hold onto those notes for yourself, but also be sure to check out my website. That's filmsbychrist.com, that's Chris the K. There will also be a link in the description to my website. It's a great place to search through all my videos and I thank you for watching. Please like, share, subscribe, comment, and also check out my Patreon page and there's other ways to support me under the support section on my website. I thank you for watching and as always, I hope that you have a great day. Ho, ho, ho and Merry Christmas. It's Christmas, did you get a new game? Did you get a new game for Christmas and it's for your computer, but they only have keyboard mappings and you want to map it to a controller, but you can't figure out how to do it. Well, that's what we're gonna do over today. We're gonna set it up so that you can map your controller to any key on a keyboard to use in any game that uses a keyboard so that you can now use the controller, even though a mouse and keyboard is better and I don't care what people say. So if you need to do this, so again, maybe you have a game and the developer didn't put in controller options but you want to use a controller or you don't like the way it's set up and they don't let you reconfigure it in the game, but you can now remap it to the keys on the keyboard for any button to be any key on the keyboard. So that's what we're gonna do today. I'm gonna use Doom as an example. Doom, I'm pretty sure probably has controller settings in it, joystick settings in it, joy controller settings, stick, go in it. Yeah, but I'm just gonna use that as an example. Who would play Doom with this when you can use a mouse and keyboard and actually use all your fingers instead of just your thumbs and maybe one or two other fingers? What we're going to use today is a program that is called, what is it called? It is called Q-JoyPad. Now you're gonna install that from your repository so if you're on a Debian-based system, so Ubuntu, Linux Mint, stuff like that, you're just gonna use whatever package you normally use but you can just sudo apt install Q-JoyPad. Once it's installed, you just run it and by default it's gonna show up in your system tray so you're gonna run it and nothing's gonna pop up but then you'll notice down by your clock in your system tray or wherever your system tray is, you'll have an icon for it, you click on it and it brings up this menu here. Normally I don't like recording my screen with a camera but I'm gonna be going back and forth from showing you stuff on the screen and showing you stuff in real life so that's just the easiest way to do it. Now by default it's gonna show you all your joysticks, all your game pads that are connected. Right now it's showing four. Really I only have one game pad connected but I have a drawing tablet that actually shows up as game control or joysticks on my system. So that's what these three are but it doesn't matter with Q-JoyPad. Once you start pressing buttons on any controller you can see oh it's telling me it's this controller and then when you click on that controller when you press a button it tells you which button that is. So it very quickly can easily detect what button is. Now there's a quick set option that will let you set all the buttons in order without having to go back and forth but we're just gonna set up a few as an example and just to show you real quick if I go into Doom here and I start the game the controller doesn't do anything, right? No it doesn't do anything. Oh actually it does. This button by default is my shoot button. So Doom by default is detecting this as a controller but nothing else seems to be working. Doesn't matter we're gonna set it up with the keyboard. So let's go ahead and just drag this back over. Now first thing that we wanna do we'll set up this for our little D-Pad here for moving left, right, back and forward. So again I can press down or up and it's the same button cause this is an axis or an axis not a button. So what I'm gonna do is I'm gonna click on this and hopefully you can see this where we're setting it to be a mouse or keyboard button and I'm gonna click this first key here and I'm going to hit W for up and I'm gonna hit this one and I'm gonna hit S for down. Okay now my left right buttons so I press that. Okay that's gonna be axis five. I'm gonna press that and in here I'm going to press A for left and D for right. Now I wanna be able to look around so I have my little axis here and it's telling me that left and right is one and up and down is two and mainly I'm gonna be looking left and right with this. I'm not gonna worry about up and down although I could. So what I'm gonna do here is I'm gonna click on this and instead of setting it to a keyboard or mouse button I'm gonna click this and I'm gonna choose either mouse vertical, mouse vertical, vertical reverse, horizontal or horizontal reverse and I'm pretty sure I want mouse horizontal because I'm looking left and right and I don't think I want it inverted. When I move this left and right it's going to act like my mouse but the speed is set to 100 which I've already tested this out is way too high. You can tweak it to your number. I am going to set it to 10. We'll give that a try. Okay now I just have to pull this out of the way. Let me go back into doom here. Use this. Oh I did forget one thing. See every time I do it I'm moving one little frame. Let me go back into our program here and what I wanna do is I wanna set this to gradient. There we go and I'll click okay. Now move this out of the way. Go back into here. This might demonstrate a little bit better. So I can go forward, back, left and right and I can turn left and right with this here. I can set this to look up and down. I haven't done that yet but you would do the same process as we did for left and right. Only you're gonna set it to vertical instead of horizontal. Real quick, let's activate our gun and our button that opens doors. So I think I want B to be my gun. Actually let's make the right trigger. So I'll press right trigger and you can see right here that it's button six. So I can go in here and I go button six and I'm gonna click key here and then I'm going to just by default it's gonna be my left mouse button. So I'll just click on there and it says mouse one. Okay. And I can do the same thing if I want more than one trigger button. I can set B to be my trigger button. So that's gonna be button three and I'll also set that to mouse click one just by clicking on that box. Now to activate door on the keyboard would be E. I'm gonna set it to A on my button keyboard here or on my controller here. It's button two. So let's click on here and I'm gonna hit or I have to click here and then click E. Okay. Now again, now I'm setting this up for doom. So I can say save and save this as doom. I can import, export, so I can move it to other computers. Let's go ahead and just move this out of the way. So you can save it, different settings for different games. And here we go. Let's go ahead and get going. Again, controlling it with a game controller is kind of weird, especially this game controller. Isn't that 64 game controller? This will open and then I should be able to shoot. So now you know you can map any button on your game to be any key on your keyboard. So now all you have to do is set this up, go into LibreOffice and type up reports with this. Whatever you want, you can control anything that uses the keyboard now with your controller here. So you can surf web pages with this with ease. So I hope you found this useful. It's not something I use much because I prefer using keyboard and mouse with a lot of games, although it does depend on the game. First person shooter, my opinion, keyboard and mouse, way, way better option. But I know people like playing on consoles and you would use a controller for that. And a controller is definitely better if you're sitting on a couch. Play around with this. It's all one word, all lowercase. So you sudo apt install jqpad, and er, no, sorry, qjoypad. And that's it. It will, you can open it up. It sits in your console. You can close it when you want. You can save your settings, export it. You can make different settings for different games. Films by chris.com, that's my website. Check it out. Link in the description to that. My Patreon page, my PayPal pages on my site, all that stuff. If you wanna support me, like, share, subscribe, comment, and I hope that you have a great day. Merry Christmas. This is a stick of RAM. You have one in your device, or at least something similar, whether it's a laptop, desktop, or even your mobile device. You have RAM. Now, obviously your phone doesn't have a big stick of RAM like this. It's probably a tiny little chip on there. In fact, laptops nowadays probably don't have something that'll look like this. They're usually smaller, or even soldered onto the board of laptops nowadays. But RAM is where things are stored before they're processed. So any application you're running, or files you have loaded, are in RAM. What if I told you you could store files on RAM? Well, put files on RAM. I wouldn't use it too much for storage. So what does that mean? Why would you do that? Well, theoretically, if you have stuff files on RAM, whether they're files or applications, theoretically they should load faster because they're in RAM, and RAM should be faster than your hard drive. Nowadays, solid-state drives and the way they are, they're pretty fast. So I don't know if you'll notice too much of a difference, but especially on older machines. On older machines, having something in RAM will make a big difference. I've noticed when I've taken, let's say I've taken a machine that's like 25, 30 years old, right? I can run Linux on them still because Linux is backwards compatible like that. But, and sometimes they'll run really well until you start saving files because writing to those old disks is super slow. Well, you could actually just put everything in RAM. Obviously, the older machines you're limited on RAM, but speed is one reason that you might wanna do it. Another time I've seen where there's RAM as drives is on small devices like a router. If you've ever worked with router where you've gotten a shell because most routers run Linux, I have found that your operating system is on a small flash, maybe only eight megabytes or 16 megabytes, but it still needs more space to run. Linux is very small and the basic tools you need to run it are small so they can fit in that eight or 16 megabytes. But to actually run and generate files, there's no room on the flash. So what they'll normally do, or at least I've seen that, I don't wanna say they normally do it, but what I've seen done is they will mount their temp directory and any place needs to be written temporarily to RAM. Now, unlike on your desktop where it's writing stuff in your temp directory to your hard drive and then it's wiped out when you reboot, these smaller devices will just mount a RAM directory because they might have 32 gigs or 32 gigs. They don't have 32 gigs, 32 megabytes of RAM. So they have more space to load things. So there's a few uses. Also, privacy. So you're writing files to your hard drive. Even if you delete them, we all know that you can, unless you override the files on the drive, they can be recovered. Well, on RAM, once you turn the power off to it, they're pretty much gone. Theoretically, they're on there for like up to a minute. If you freeze the RAM with a cold boot attack, it might be a couple of minutes, highly unlikely. But if you have files that you don't want someone to be able to recover but you want to manipulate or whatever on your device, you can load them to RAM. So that's what we're gonna do today. We're going to create a directory on our device and then say, take part of my RAM and make it storage on that folder. And then anything you put in there, well, again, not only load faster, but when you restart the device should be completely wiped out and for the most part, not recoverable. So let's go ahead. May not be something you do often, but it doesn't hurt to know and it's really, really simple. Literally, one to two commands. One command to create a directory and another command to say, mount a specific amount of RAM to that directory. Okay, here we go. This is again, super simple. Link notes in the description, but again, it's two commands. The first one, we're gonna create a directory which you can do in your home directory or anywhere on your system. If you are doing your home directory, you don't need sudo. If you're mounting it in a directory, like we're going to, you'll need to sudo to at least create the directory. You'll still need sudo to mount the directory, but we'll just make a directory under MNT and we'll call it tempfs because it's a temporary file system. So we've created that directory and now all we have to do is say sudo mount and then we're gonna say dash o size equals and in this case, I'll say one gig. So I'm gonna say I want it to be one gig in size. Next, I'm gonna say dash t for type and I'm gonna say tempfs because it's a temporary file system. They're gonna say none. I'm not really sure what none is for. It's just in my notes. And then we're gonna say where we're going to put it. And again, it's gonna be that tempfs under MNT. And that is it. If I was to run mounts now, you can see, got a little smaller, so everything's on one line for one moment. You can see here that we have mounted a temp file system. It tells you the size there in kilobytes. If I was to df-h, it'll list all my drives and you can see that it's a temp file, or it's mounted a temp file system and the size is one gig and it's one gig available so I haven't written anything to there. So let's go ahead and go into that directory, tempfs and I could echo test into a file test. I can date into a date file and now we have files there. I can df-h and you can see that we've used a little bit of space, but this is in RAM. Anything I put on here and again you can copy applications here and theoretically those applications will load faster because they're loading from RAM. But that's pretty much it, is that simple. Now when I restart this directory, the directory will still exist but the stuff in it will be completely gone and they were never written to the hard drive so they can't be recovered from your hard drive. If I was to move out of this directory, I can sudo, you mount and I will unmount that directory. Theoretically they're still in your RAM, I would assume but RAM is being written to all times, it's gonna be all written and again, once power is cut to it, that stuff is gonna disappear. So again this is, if you're really paranoid and you wanna make sure that files aren't recoverable but you're able to manipulate and use them how you can, you can obviously download files to that directory, use them and then when you reboot, it's gone. So that's it. Our whole system isn't, now be aware if you're doing this for privacy reasons and you open up something like GIMP and you're manipulating an image. It may be, GIMP might be storing files and copies of those files into other directories so that's something you need to be aware of. Might be your temp directory or somewhere in your home directory. I really don't know, I'm just saying that as a blanket example. But if you're in the shell and you're creating stuff and modifying stuff, you're pretty much sure that everything you're writing is going where you're writing and there are backup and temp and recovery and history files. But that's it. Super simple. Again, there's a link in the description to the two commands but the main command you're looking at is this mount command. Again you can change this to basically any size, just make sure it's within the size of your RAM and you still need RAM to work as RAM. So if you have eight gigs or 16 gigs or 32 gigs don't make the file, the mounted directory that size. I would assume that would cause problems. I haven't tried it. I don't even know if it will let you do that. But that's it. Thanks for watching filmsbychris.com. That's Chris at the K. There's a link in the description. As always, I hope that you have a great day. Hello and welcome to a video from filmsbychris.com. That's Chris at the K. I am Chris. There's a link to my website in the description of this video. And today we're gonna be looking at a poor man's port scanner. Now if you need to do port scanning, my personal opinion, the best port scanner out there is gonna be Nmap. And you should use that if you can. But let's say you don't have Nmap. There are other options that you may not know about. Nmap is easy to install on systems. But if you're on a minimal system, you may not. But if you have Bash, and I specifically say Bash, because this is a Bash feature, you may not know about unless you've been around the Linux world for a while, is that Bash actually has networking capabilities built in. If I was to list out stuff in my dev directory, which is my devices, so basically mostly hardware stuff, you can see all this stuff here. Video would usually be webcams or other video inputs. But if we look at T's here, see we have these TTY's, but there's no TCP. Now if I was to echo into dev and give it a file name that either exists or doesn't exist, most cases I'm gonna get a permission denied. I don't have permission to write stuff there. But if I was to write to TCP and give it a number and then another number, it just kind of hangs. What's going on there? Why is it not giving me permission denied or file does not exist or something along those lines? Control C to kill that. Because even though you don't see the dev TCP inside that directory, it does exist within Bash. Bash will create these things as we go. So if I was to echo into that, I could give it a IP address or domain name and a port and I can retrieve information or at least detect information from those servers. You can use this to pull down files and webpages from the internet. The problem with it, and that's something you can look up and I can go over in this video. It's not as useful as it used to be because of HTTPS. As far as I know, HTTPS, the encryption doesn't work through this. So you'll just basically get an error if anyone can correct me and point me to tutorials on doing this with HTTPS. That'd be great. But even though it's not as useful as it used to be for downloading files and information from web servers, you can still use it as a port scanner. Now there'll be directions or notes in the description of this video to everything I'm about to go over. But if I was to echo into my dev TCP, again, give it an IP address or a domain name. I'll just give it 127.0.0.1, which is the same as localhost. So I'm pointing it at my own machine and then I go forward slash in a port number. In this case, I'll do eight, right? What are we gonna do? Oh, we get an error connection refuse because I don't have port eight open. But if I would say port 80, which I do because I'm running a web server on my computer, I get no error. So of course we can detect what's the last command successful or not. So here I can say ampersand ampersand and I can say echo port is open. And when I do that, I get port is open. But if I was to go back to like any port that's not open, but I'll do eight again, you can see we get our error. Now we can always then say our or operator. So pipe pipe and I can say echo port is closed. And now we'll get our error message with port is closed. So we have port is closed. And if I was to scan port 80, we have port is open. Now let's say we don't probably don't want this error message. We just want to know that the port is closed. What I could do is wrap this in parentheses and then say two greater than and pipe all the errors into dev null. And now we'll get either port is open or port is closed. And of course we can do this with a for loop now to loop through everything. So I'm not going to print out if a port is closed because I'm going to be scanning a bunch of directories. So what we're going to do here is we're just going to say four and we're going to create a variable called i and we're going to loop through the number 20, in this case to 10,000. You can also give it a list of ports that you want to scan, but I'm just going to scan a bunch of ports. Then we're going to take that information and we're going to, again, echo basically nothing, basically putting a new line character into dev TCP and then an IP address or domain name and then that port that we're generating over here, dump all errors into null and then we'll just, if the port is open, if that is successful, we'll say port and then give it the port name is open. I'll run that on my local host here and you can see it's listing all my open ports. And it doesn't take too long because I'm running on my local machine. If you were to do a remote machine, it'd be a little bit slower, but I could do something like so. I could say instead of looking at my local host, I'll just point it at my router and I will run this and now it's going to start listing all the open ports on my router. So that is a poor man's port scanner. So again, this is a functionality of bash and possibly other shells. I know it doesn't work in Z shell, but it's built in bash and that's why you won't see this directory because it doesn't really exist. If you just look at it in bash, bash goes, okay, we're looking for a server, a port and again, there's commands you can do to download files from a website or other network operations, but again, with current modern web sites, mostly using HTTPS that's, as far as I know has become mostly useless. But if you are on a bash system, you don't have Nmap and you need to do a quick simple scan of ports, this is something you can do. Again, there's links in the description of this video to all the notes that went over, so you can look at those. I hope that, again, this is not something you're probably gonna use regularly because Nmap is just a better option, but in a pinch, having this information, this knowledge could be very useful. I thank you for watching. Please visit my website, filmsbychris.com. Again, that's Chris the K. There'll be a link in the description. I also have a Patreon page. I have a PayPal account and a Libre Pay account. If you couldn't support me financially, oh, that would be so great. I would appreciate it. If not, I do thank you for watching, for sharing, subscribing, commenting, giving thumbs up or likes or whatever, and I just hope that you have a great day. Hello and welcome to a video from filmsbychris.com. I am Chris, that's Chris with the K. Link in the description of my website. Today we're gonna be creating a script just to make life easier, right? So if you're on a Linux system, you have package managers. Depending on what system you have, you have different package managers. I am on a Debian system. And if you're on a Debian-based system, you're using some sort of app. So apt or apt-get or I prefer aptitude. So if I was to use aptitude, I could search, for example, if I was looking to install package, I could say search bash and it will list all applications with the name bash in it. And so then I can take one of those. Let's say I want to install bash. I mean, or have it installed. Let me go sudo apt install or actually I can do aptitude install and I will give it the bash name. It'll ask for my password and I will run that. It's already installed. It will tell me that it's already installed and that is fine. So what I want to do though is I want to be able to have this list come up and then filter through that by typing and then grab multiple packages and have them all installed. And we're gonna do that using aptitude and FZF. We're gonna write a script. It's gonna be less than 10 lines long for sure. Maybe closer to five. But let's go ahead and just look at this real quick. So again, I can do this to search for the phrase bash, right? And what I can do is I can pipe that into FZF and it will give me that list and then I can type in something like top and there's bash top. I could enter and it returns that. If I want to select multiple files, I can say FZF-M. And now when I do that, I can say top. I can say tab on that one, tab on that one, and now it lists out all three that I had selected with the tab. Great, but of course we want to give it some sort of prompt so the user knows what to do. Dash dash prompt and then what we want it to say we'll say select packages. And we'll make that look nice. We'll run that and now we have our little select packages. I can type in something like node and I can select whatever packages I want here. I type node wrong but it still filtered it fairly decently and we'll run that and it lists those out. Okay, we just want the package name, right? So that's the second column. So what we can do here is we can now put this into AUK and I can do curly braces there or whatever you want to call them. And I'll say print dollar sign two. That's the second column. So now we still get our full list with the description. Again, I can say node and I can tab through those three and now it gives us a list of just the package names but we want those all on one line but with spaces between them. So real simply, we'll just put that into TR. We'll say backslash n. So we're going to convert all new lines to spaces. Again, I'll just do node. I'll do tab, tab, tab or however many of these I want and then it lists them all in a row. Now we can just take that output and we can put it into our apt or aptitude or apt get command to download. So let's go ahead and start working on this as a script. Okay, so I'm going to say vim and I'll call this app search. You can call it appsearch.sh if you want and my vim configuration automatically puts this header into all my script files, my shell script files. So that's good. You just need the bash shebang line there saying that this is a bash script and first thing we need to do is the user giving an input. So when we run our script, is the user giving us a search query? So I'll just say, look at the first argument. Okay, is there a first argument? If there is a first argument, we're going to say q equals whatever that first argument is. Okay, now let's say the user doesn't give us any input when it runs the command initially, when they run the command initially. So we'll say our or operator, so pipe pipe, we're going to use the read command dash p and give it a prompt and we'll say enter search query. Whoa, there we go. And then we'll create that variable q. So we're either looking at, did they pass it when they typed in the command, if not request it, and then we'll check, did the user actually give us anything? If they didn't, well, then we're just going to exit right there. Okay, and real quick, just to show y'all echo out q. We'll save that. We will make it executable, like so. Now, again, we have our script in our directory here, I'll dot slash that. And if I give it something like bash, it will echo out bash, because that's why I typed. If I give it nothing, then it will ask me for something that can type in bash or whatever I wanna search for. Great, now we're gonna move on. We're going to run our command that we created earlier and put that into a variable. So let's go ahead back into our script here and just to save time, I will copy and paste. I'll delete that echo line because we don't need that. That was just for demonstration purposes. So I am going to say this. We're gonna say we're running our aptitude search with our query up here as long as something was passed. Otherwise, we've already exited. We're gonna put that into FCF, search, make sure we're selecting multiple files if we need to, putting all those on one line and putting that into a variable called pkg. Now, we wanna make sure that we actually selected stuff, because if we didn't, we're just gonna exit at this point. So we're gonna say, okay, pkg, should we exit now? I don't need the quotation marks around these variables when we're checking them, but just to be consistent, I'm either gonna have them or not have them. So now we have quotation marks around that. Okay, so again, now I can run our script. I can say bash, it's going to search for bash and now I have a list I can filter through. So I give it an initial search and then it will give me a list that I can filter through and select from, right? And, or if I didn't, I can say something like node, right? And it's gonna give a long list node stuff and I can say bash, there we go, I selected one. Okay, so let's finish it off. We now, as long as we have selected something from that list, we are now going to run this. We're going to sudo apt install the packages, right? So let's go ahead and give that a try. I will run our script, I'll say bash, and I will just check things I already have installed. Like so, just so we don't install anything I don't want. We'll run that and you can see all those are up to date. If they weren't, they would have been installed. And if we were to not give anything here, I could type bash here or whatever I want my search query to be to narrow down the list. If I don't give anything, it exits. If I was to give it something and I was to go here, let's say I was to type in stuff that doesn't exist and I have nothing selected, it should exit out before it gets to that. So again, we have a nice little script here. One, two, three, four, five lines of code. And now you have a quick way to search through packages. Not that it was hard to do it with just aptitude search, but now it's able to filter through the list a little bit quicker and easier. So now instead of running aptitude search query, find the package name aptitude install, aptitude install package name. You just run, once you put this inside your system path, your app search, search for your package, filter the list, select multiples if you want, and it's installed. I'll put a link to this script in the description of this video. I hope you check it out and I hope you find it useful. Please visit my website. Again, filmsbychris.com, that's Chris of the K. And there you can also find links to my Patreon page, my Libre account and my PayPal account. If you could support me somehow financially, that would be amazing and I'll stop singing if you do that for me. And if not, I do thank you just for watching. Sharing this video with other people who think might like it would be awesome as well. Giving it a like and a comment would also be appreciated. But if anything, I just hope that you have a great day. Okay, here I am. I'm going to echo out this multi-line string. Not a problem, right? It does it, great job. But let's say I wanted to store that string. There's a few things here that might be issues. One, it's multi-line. So we may want to remove those new lines, which we could use set or TR to do that, but we also want to preserve those. So if we're going to take the string and put it into a database or a JSON file or some other type of storage, we kind of want it all on one line but to preserve where the new line characters are. We also have these quotation marks that could cause problems. And I also have a Unicode character here that could cause problems. So how can we easily convert all this? Yeah, you could use SED and OCK and stuff like that, but actually the tool JQ, which is used for parsing through JSON files, can actually do this for you. So again, quotation marks. You know, if I wanted to, I could go like this. I could backslash them out and that would work, but I would have to do that for each quotation mark. And we may not know the string. We may be pulling data from someplace using a script and we want to automatically put these backslashes in there. And also again, we want to convert this Unicode character to something a little more compatible and again, preserve those new line characters. So let's go up to our first example here. And what I'm going to do is I'm going to pipe this into JQ. Now, JQ may not be installed on your system by default, but will most likely be in your repositories for your Linux system. So go ahead and install that. It's a very useful tool. And what I'm going to say here is if I say dash capital R and then a period, what we're going to do here, what does that do? Well, that automatically went ahead and put backslashes before our quotation marks there. And it will do it for other characters as well. In certain cases, it will just take care of that for you. You don't have to come up with your own little algorithm to figure that out. Now we still have everything here with the Unicode characters. So what I can add to that is dash A. So lowercase a, so dash R, lowercase a. And now it converted that into a more compatible format for us. But we still have everything as multiple strings. Each line is a new string. We don't want that. So let's go ahead, run the same command. We're going to add S for slurp, is what it stands for if you read the man file. And now we have everything on one line, in a string, properly quotated with the quotations around the end there. We have backslashes before these quotation marks. We have our Unicode character now converted to a more compatible format. And then we also have all our new line characters. Now, if I was to take this, highlight it, and you'll see. We store that somewhere. We pull it out. And then here we're going to echo it back out. You can see echo will automatically put everything back how it's supposed to be. So that that's a very usable string there rather than what we had before with all the uniqueness to it. Again, if you want to see more of what these commands, the capital R, lowercase S and A do, you can look in the man file. We do forward slash capital R. You can see here this takes the raw input. And that's going to again do the backslashes for us. We have S for slurp, which is going to put everything on one line instead of ring it as arrays. And then if we do our dash A here, you can see that it's going to take non-asky Unicode code points and convert them to UTF-8, which is just a little more compatible for most systems. So I hope you found that useful. I have found this useful a few times because it used to be when I had things like this, I would try to do it myself. I would try to use sed or TR to go through oh, find all the quotation marks and backslash them. And you could do that, but there's already tools out there. This is just one, I'm sure there's other, but I use JQ for a lot of things because I do a lot of stuff with JSON and just having this little option here makes it so much easier to just make those strings that I have and make sure that they are compatible with more things. So thanks for watching filmsbychrist.com. That's Chris the Gay. There's a link in the description of my website as well as my Patreon page on my website. You can search through all my videos as well as go to the support section maybe, and support me again. I have Libre, Pay, PayPal, Patreon. If you can't support me that way, be sure to like, share, subscribe, commenting, and I always just, I thank you for watching. I hope that you have a great day. Okay, here I am. I'm going to echo out this multi-line string. Not a problem, right? It does it, great job. But let's say I wanted to store that string. There's a few things here that might be issues. It's multi-line. So we may want to remove those new lines, which we could use sed or tr to do that, but we also want to preserve those. So if we're going to take the string and put it into a database or a JSON file or some other type of storage, we kind of want it all on one line, but to preserve where the new line characters are. We also have these quotation marks that could cause problems. And I also have a Unicode character here that could cause problems. So how can we easily convert all this? Yeah, you could use sed and oc and stuff like that, but actually the tool JQ, which is used for parsing through JSON files, can actually do this for you. So again, quotation marks. You know, if I wanted to, I could go like this. I could backslash them out and that would work, but I would have to do that for each quotation mark. And we may not know the string. We may be pulling data from someplace using a script and we want to automatically put these backslashes in there. And also again, we want to convert this Unicode character to something a little more compatible and again, preserve those new line characters. So let's go up to our first example here. And what I'm going to do is I'm going to pipe this into JQ. Now JQ may not be installed on your system by default, but will most likely be in your repositories for your Linux system. So go ahead and install that. It's a very useful tool. And what I'm going to say here is if I say dash capital R and then a period, what we're going to do here, what does that do? Well, that automatically went ahead and put backslashes before our quotation marks there. And it will do it for other characters as well in certain cases. It will just take care of that for you. You don't have to come up with your own little algorithm to figure that out. Now we still have everything here with the Unicode characters. So what I can add to that is dash A. So lowercase A, so dash R, lowercase A. And now it converted that into a more compatible format for us. But we still have everything as multiple strings. Each line is a new string. We don't want that. So let's go ahead, run the same command. We're going to add S for slurp is what it stands for if you read the man file. And now we have everything on one line, in a string, properly quoted with the quotations around the end there. We have backslashes before these quotation marks. We have our Unicode character now converted to a more compatible format. And then we also have all our new line characters. Now, if I was to take this, highlight it, and you'll see, so if we store that somewhere, we pull it out and then here we're going to echo it back out. You can see echo will automatically put everything back how it's supposed to be. So that's a very usable string there rather than what we had before with all the uniqueness to it. Again, if you want to see more of what these commands, the capital R, lowercase S and A do, you can look in the man file. We do forward slash capital R. You can see here, this takes the raw input and that's going to again do the backslashes for us. We have S for slurp, which is going to put everything on one line. So ring it as a raise. And then if we do our dash A here, you can see that's going to take non-ASCII Unicode code points and convert them to UTF-8, which is just a little more compatible for most systems. So I hope you found that useful. I have found this useful a few times because it used to be when I had things like this, I would try to do it myself. I would try to use sed or TR to go through and find all the quotation marks and backslash them. And you could do that, but there's already tools out there. This is just one, I'm sure there's other, but I use JQ for a lot of things because I do a lot of stuff with JSON and just having this little option here makes it so much easier to just make those strings that I have and make sure that they are compatible with more things. So thanks for watching filmsbychrist.com. That's Chris the K. There's a link in the description to my website as well as my Patreon page on my website. You can search through all my videos as well as go to the support section maybe and support me again. I have Libre, Pay, PayPal, Patreon if you can't support me. That way be sure to like, share, subscribe, commenting and I always just, I thank you for watching. I hope that you have a great day.