 Okay, today we're going to be looking, I'm working in the bash shell here on my Linux machine and we're going to be looking at splitting strings based on spaces into separate variables. So here's an example. Let's say I create a variable called my var and I set a variable, I set it to this is a test and I can of course echo out my var and it says this is a test. Using the set command I can say set space dash dash and the name of my variable dollar sign my var. Now if I echo dollar sign 1, 2, 3 and 4 you can see that it split each of those variables that string into each of those variables. So how is this useful? Well let's look at some examples, let's look at other ways to do something real quick. So if I if config I can see my network information, let's say I want my IP address here. I could do something like, excuse me, I have config, I can grep for init and then I can pipe that into head dash and 1 just to make sure I'm just grabbing the first instance of that. I could also say which network card I want but right now I'm just going to head and I'm going to say cut dash d and space space dash 10. So there's two spaces here so we're saying the delimiter is a space and then I want column 10 based on that and I get my IP address, my local IP address which is great and actually it probably better because it's a little confusing having that space space there. Another option would be to use awk, I can say awk print dollar sign 2 saying column 2 here. So there we go it gets me the same result, it's just a little bit clearer than someone might not see those two spaces there if they were looking at this command. Okay so that's great and I can pipe that into a variable. So if I wanted to set my IP to a variable called IP I can say IP equals inside quotations dollar sign inside parentheses. Now anytime I echo dollar sign IP I have my IP address and I can do the same if I wanted the netmask I can say I'll just do nm for netmask and that's column 4 and now I can echo dollar sign nm and I have my netmask and then I can do the same thing if I want my broadcast IP so I can say 6 and here I'll say I'm going to call it bc that doesn't matter there's a command called bc that doesn't matter okay echo dollar sign bc and you can see I now have that so again if we if config you can see that we have cut this this IP this IP in a broadcast IP here that works but can we simplify that using what we've learned with the set command and we can very simply. So what we can do is just like before we can say set dash dash and then before we gave it a string so that string can be an output of a command. So basically let's look at this command we're going to do our if config command here like this but what we're going to do is we're just going to say head one which just gives us that line and with a set command we can now split things up based on numbers. So what I can do is just this I'll put that inside parentheses and I'll say set dash dash dollar sign parentheses so we're going to run that command which gives us this output and sets going to set variables for each of those for us. Now if I want my IP address I can say echo dollar sign 2 if I want my net mask I can say the dollar sign 4 and if I want my broadcast I can say 6 so with this one command I quickly created three variables they're not well labeled variables but it is very simple to do. Now one thing you don't want to do is I like to usually put things like this in quotation marks so it holds it together and most times that's good but if we do that now I believe it messes things up yeah as you can see I can only do echo one and it's all that entire string because it kind of put it all together. Anyway again so just the set without these quotations so set dash dash and our command there and now I can echo dollar sign 2, 4 and 6 for this example so again this one command was a bit quicker than running our three other commands which were this command, this command and this command we replaced those three running those three with one command using the set command. I hope you do find that useful I hope you enjoy this tutorial I hope you enjoy all my tutorials sure check them out filmsbychrist.com that's Chris Decatur's link in the description of the video to my website and there you can search through all my videos from both my channels I have thousands of videos thousands of tutorials many of them on the Linux shell be sure to check them out and if you enjoy them if you join my videos in general think about supporting patreon.com forward slash mail x1000 link in the description of the video you can also support me through PayPal there's a link on my website to that I thank you for watching and as always I hope you share like share like share subscribe comment all that good stuff helps out a lot and I hope you have a great day