 Okay, welcome back to our Shell Command Tutorials 2017. Again, these tutorials are more for, they're not beginners, they're not really advanced, they're more for intermediate tutorials, I would say. But let's go ahead and look at the, we're gonna try to find bootable partitions. Now, things have changed over the years. Some, in some cases, partitions don't need to be marked as bootable for them to boot, but sometimes you do. I'm not gonna get into the details of that, but today we're gonna look at finding which partitions are marked as bootable on a device. So I have a bootable Linux, I believe, Linux Mint flash drive plugged into my machine right now, and one of the drives, one of the partitions on it is marked as bootable. We're gonna go ahead and use FDisk. FDisk is a tool that gives you and allows you, gives you information about partitions and allows you to modify them. But if we do, you have to be root or pseudo to use it. So I'm gonna pseudo FDisk-L will list all hard drives and partitions currently hooked to my machine, whether they're mounted or not. So there you go, you see we got a few. I've actually got SD-A, SD-B, and SD-C. So one, SD-A is my solid state drive that runs my system. SD-B is a terabyte drive I have for my larger files. And then SD-C is my bootable flash drive. And that's the one, as you can see, there's a column here marked boot. And for that drive, there is a bootable partition on it right there. You can see that it's marked with that little asterisk. So let's say we were writing a script and we had to find all bootable partitions on the system. Well, we would run that command and then you might think, oh, I can grep for the asterisk, which you could. That would be the first thing I would do. So I would say grep asterisk like that. But you see, you return some other things because there's other lines in that output that have asterisks in it. So you could also, you know, grep and then grep again for lines that have dev in them, and that would work. And then if I wanted to get just the partition name, that part right there, I could then pipe it. And this is what I would probably do if I was just doing this on the fly. I would say awk, I would say print, and this has to be in curly braces, dollar sign one. And that would give us that. So what this is doing is it's saying, okay, list all partitions, find every line of the output that has an asterisk in it, then find out those lines, which one has the dev line in it, and then print just the first column of that. And that works, but we're running one, two, three, four commands. Let's cut that down a little bit and just run two commands. Just be a little more efficient about it. So that's one way to do it. Let's run it again, but instead of grepping, awk can do grepping type stuff as well. So I can say awk, and I can say dollar sign two equals, and then quotation marks here, asterisk. And you can see right away that gives us the proper lines. So what this is saying is, okay, we're getting the output of all the information of all our partitions, and it's telling awk to look at the second column of all the output. And if the second column equals an asterisk, then print that line. So whereas with this one, when we were just grepping, you can see if awk we're telling to only look in the second column, well these asterisks on these lines we don't want are not in the second column. This is the second column for those lines. So right away, we've got one command that does the double grepping that we did before, and really I could have issued those in a single grep most likely. But either way, there we go. But now we want to get just this output. So this is saying again, awk, look at second column, any line that has a second column. Right now it's saying print that whole line, but we can tell it just like we did before but with the awk command. But instead of in a separate awk command, in the same awk command we can say only print the first column. So it's searching the second column for this but only printing the first column and there we go, in two commands we get every partition. And if I had multiple USB drives in there, actually let me grab another USB drive and plug it in real quick, run that command again. Aw, look at that, we've got two. So I got two bootable USB drives and we know which drives and partitions right away with this single one liner here are marked as bootable. So for some reason you need a script that would find all bootable partitions to do something to them or just to log that. This is a command that does that. I do thank you for watching, I hope you found this useful. As always, please visit filmsbychrist.com, that's Chris the K, there's a link in the description as well as link to my Patreon page where you can become a supporter, you can also find the supporting links on my website under the support section where you can support me through PayPal or with Patreon. I do thank you for watching as always, I hope that you have a great day.