 Hello and welcome. Today we are going to be working with Bash and we're going to be generating some fake information for some real world scenarios. I'm constantly asked by people to give real world scenarios with scripting so that's what we're going to do but we need some fake data to generate. So basically what we need to create is we need to create a spreadsheet that has a column of people's names and then we're going to have 25 columns with pretend yearly salaries for each of those people for 25 years and we'll get into using this data that we're going to generate in future videos but let's go ahead and first thing we want to do is go to gitlab.com forward slash middle x1000 forward slash documents dash tutorials. I'll try to remember to put a link to that in the description of the video and you'll want to clone this repositories if you don't know what cloning is just click this and click download a zip file and extract it. Once you do that you'll be presented with a folder with a couple files and a folder called yearly salaries and I'm in that folder right now and I have some shell scripts and we're going to go over again next couple of videos each one of these shell scripts I've created I'm going to show you what they do and then I'll explain how they work and the first one I'm going to run is this get people which is really just one command in there if I cat it out you can see it's a W get command which dumps this pay spin post to people.csv which is just this file right here which I've used tutorials before it's a list of fake names addresses and phone numbers birth dates that I've generated based on real information so it's realistic but fake for using in projects like this so let's go ahead and run that script to download it so people dot I'm sorry get people and that will download that file so now we have that file and again I can cat that out but that's not what we need we need a column of names and a column and 25 columns of payroll so there's another script in here called it's this create csv so I say dot slash create csv I'll run it show you what generates and then we'll look at the script itself so it's creating it and basically what's going to be doing is we taking random names from that people file and then generating random pay scale amounts for each year for 25 years it's complete we can cat out that file it's called salaries.csv that's what it looks like we can open it with something like Libre office salaries.csv and we're going to want to say it's commas and the limiter is quotation marks you can see the preview looks good okay and here we have it we have a column for the first name or last name column for the first name and then we have 25 columns of randomly generated fake pay for those people their salaries let's look at the script that we just ran create csv and see how it works first thing is first well first things first we have shebang line then we are echoing out this little line just letting you know it's doing something and then we're going to loop a hundred times because we're gonna generate a hundred random entries I've talked about this in previous videos we're going to now shuffle the people file and we're going to grab one line from there so we're going to randomly grab a line from the people csv file and we use the cut command and we're going to cut based on commas because the comma separated file and we're going to say we want columns two and three which are the last name and first name and then I'm going to remove the new line character at the end and then this next line is going to add a comma to the end of that so let's give us a last name first name so be last name comma first name comma comma and then we're going to continue adding that line again this dash n means no new line at the end so we're going to continue adding that and what we're going to do is we're going to loop 25 times for 25 years and then we're going to echo out this now what does this do what it's saying here is we are echoing with no new line character because we're going to loop 25 times in fact I could make this a little easier to read if I did this just slightly easier to read like that and in fact we can move this to a new line so we're doing here as we're saying echo and then we have a quotation mark and then we want quotation marks and a dollar sign why do we want quotation marks because our numbers going to have commas in it and so we need that string delimiter in our csv file there are no commas in the numbers we wouldn't need that I'm going to add a dollar sign here the backslash says use this actually print a dollar sign but the next one's saying run this command again we're going to shuffle numbers so we're going to give it a range of numbers from 30,000 to 120,000 that's going to be our salary range and we're going to return one random number between these two numbers the next command here is a said command which I've talked about in previous videos that basically just adds commas to that number we could also use numformat which is a much easier thing to read it's just numformat dash dash g and that's a very common tool but I was going to say I use said in this while you said this command because I didn't know of the numformat command when I first wrote this script but also I'm leaving it there because said is on pretty much everything it's part of busybox so I mean it's on your phone where the numformat may not be I'm not sure if it is I haven't checked how common it is but basically this is just putting commas every third number so that's just generating 25 different random salaries and putting them in a line and then this last echo after this loop finishes and generates 25 numbers adds a new line and then it loops again and it's dumping all that into the salaries.csv file and then it goes out complete so again if I leave our office our people but salaries.csv again we use commas our quotation marks for our donors because there are commas in our numbers this is what it generates and if you look right here you look at some of the names we can now say you know the second one here is Paul Norbury the first ones Rebecca then Robert if we were to run our create.csv again and this takes a little while because it's not only grabbing names from that file one at a time randomly it's also generating a lot of numbers we're gonna go in here and same options there and you can see it generated different names now we got Debra or Debra Debra James so this generate all new names all new numbers every time we run that script it generates a hundred of them again with 25 years worth of salary logs and again if I go into our create.csv or create underscore csv.sh file one thing I could do is change this and this should do the same thing I'll go num format dash dash g I believe is the proper command so what I think I need to let me undo that because I removed some things I didn't want to remove yes because I didn't want to remove that comma so sorry about that num format dash dash g I believe if I remember correctly is the command running again and we'll open this up click okay they can see it did the same thing again random names random numbers but it's a little bit easier to read either option I think I've shown you three different options and again num format is a very common tool it's part of the core utilities package here on Debian but I'm not sure if it's on lightweight systems like if you went to a router or something this may not be there where said probably will be or could easily be put so yeah just another option there these are all things commands that we've gone over in the past and we're just putting them to use now I hope you found this tutorial useful please visit filmsbychrist.com in the next video we're gonna start manipulating that data for some usage anyway thank you for watching and as always I hope that you have a great day