 Okay, this video is actually outside of my regular series. I just have a friend working on a project. I'm trying to explain stuff to him through messaging. So I thought I'd do this quick video. Basically he has some JSON and he wants to, with a bash script, convert one of the values. It's math, it's numbers, he wants to do some math to it. I'm gonna give a very basic example that will hopefully point him in the right direction. I created this test.json file, which just has three items per row in there. And actually it's not even properly formatted, there should be a comma there. It doesn't matter for what we're doing. I just wanna show you, we're gonna take this second column here for each number and we're gonna do some maths to it. We're gonna divide it in half and then replace the original. And there's probably a better way to do it than I'm about to do it. Probably using regular expressions and stuff. But this is just the quick and dirty way that came to mind while texting with him. So first thing I'm gonna do is I'm going to cat out that file. Now I'm gonna say while read the line. I'm gonna say do, and of course we can echo dollar sign line. Done, which is gonna give us basically the same output as before. But I wanna put our value into a variable for each line. So basically I wanna get this number and this number and this number. So let's go ahead, oops, and let's just use cut a couple of times. Again, not the cleanest way to do it, but we're gonna cut. And we're gonna go one, two, three, I think. So right there. And then we're going to pipe that into cut again and use a delimiter of a comma, field one. There we go. So now we have each number. So I wanna put that into a variable. So I'm gonna take that, I'm just gonna call it x, x equals. And then in quotations and in parentheses saying, put the output of this command into this variable. But since it's a loop, it's gonna be doing that over and over again, replacing x each time. And I didn't cat anything out or echo anything out. So it did that, but didn't print anything to the screen. So let's go ahead and add to it. We're gonna say echo dollar sign x like so and we're back to getting our column there. Let's go ahead and do some math to this. And we're just gonna use BC. So I'm gonna say, let's say we divide each number by two. So I'm gonna say echo that number, dollar sign x, divide by two into BC. And we get the, now and also this is, we're rounding here, we're not doing any decimals here. But again, it's not the exact math he's doing. I'm just giving him the idea of how to do this in a loop. So now we have that value. Let's put that into y for each lines. We'll say y equals and inside quotations, dollar sign parentheses, we're going to do that. Now, just to make sure we have the right output, I'm gonna say echo dollar sign x is now dollar sign y. And I'll print out the screen. We haven't changed the file yet, but there we go. So this is the origin number. This is it halfed and rounded. So instead of printing it to the screen, let's use said to replace our original file, make a backup of your original file before you start messing with it like this. But I'm just gonna go say said dash i to replace the change in place. We're modifying the file instead of just outputting the screen. Again, it's test.json. And we're gonna say s, forward slash forward slash g. So we're gonna substitute globally and we're gonna say dollar sign x with dollar sign y. And again, this is a very sloppy way to do it. Because if any of the other columns have that exact number, you're gonna be modifying that too. But in this particular case, that doesn't matter. He's basically, he's converting GPS coordinates. And so anytime there's a GPS coordinate, he's gonna do the same math to it. So it doesn't matter if it's found someplace else. But we do that. And now if I cat out test.json, you can see our second column now has our new numbers rather than the old numbers. And that is an example on how to do that. Very sloppily, all online here. But hopefully it'll point him in the right direction. And I'm just doing this video to make it easier for him. And I'm sharing it with everybody in case it helps you. Again, I'm not saying this is the best way to do it, but it's a quick down, dirty way to do it. At least get something working before you can come up with a better solution. Sometimes that's what programming is. Getting it done, fixing it later. I thank you for watching as always. I hope that you have a great day. Please visit filmsbychris.com. That's Chris the K. There's a link in the description. Have a great day.