 Alright, what's up everyone? So I don't have my webcam today. Hopefully you can pay attention. I'm at work, so I don't have it but I want to illustrate the difference between minimalism and meme minimalism because there is a difference and I do not endorse memes. I endorse doing things efficiently This is sort of a response to a response video of mine There's a video by this channel distro tube and he says why use Catergrap when you can use AUK and This I'll go ahead and say the video that this video is a response to is something that I said a little bit ago I said that I see so many people doing something silly like this catting files and then piping them into other programs like grep. So for example catting this file config piping it into grep to search for the sequence i3 Okay, now that works, but that is not the correct way to do it You grep or yeah, you grep directly on the file searching for i3 the results are the same But this first one is less efficient. It is not only you know more characters in your script as this as if anyone cares But you're running an extra program and cat is a small program But it makes a big difference and I'm gonna show you exactly how big that difference is in this video Now I will say I'll make one rejoinder to some things that people said I have no problem if you are on the command line and you have just cat it out a file And you want to grep it now and so you go back up and add Grep at the end. I'm okay with that what I Made this original video for is for when you're writing in scripts You should always always always do it this way because there is no reason for you to have that extra Program running it is pointless. Okay now distro tube I don't want to say he misunderstood now the video is not bad I'm not I'm not downplaying it because he does talk about some of the useful things you can do with arc and said and stuff like that But I think it is replying It's missing the point of my original video because my original point is things getting done with maximal computational efficiency not running through things, you know It's not about avoiding programs because what he says is well if you can avoid cat You can easily avoid grep as well because you can grep with a program like arc You can do something like this and that produces the same output now, of course grep has extra features like you can You know highlight What whatever the matches but awk can do pretty much everything grep does now Here is my rejoinder to that awk is not as efficient in terms of you know CPU usage or time or anything at Grepping grep is the best program to grep with said is not good for grepping either use grep for grepping So let me show you first. I'll show you. Well. Here's what we're gonna do. I'm gonna say 4x in Sequence a thousand so here's what I'm gonna do. I'm gonna run a thousand times the The example I just give you a second ago first Let's cat the config file into I or into grep to search for a sequence. Oops. I did not mean to actually run that So we'll cat that into that. Let's actually make it, you know, not ZSH so other people can follow along So if we do that actually let me silence the output too So it's not messy because that's a big mess So we'll make what grep quiet and I'm gonna run the command time on this entire sequence So we're gonna see how long it takes for all this to run. Okay? Waiting for a second a couple seconds Okay, so this ran this command 1,000 times and you'll see that it took 4.2 seconds Here's our CPU usage, etc. Etc. So again, this is the wrong way to run it. Let's run it the correct way Okay, so we will Get rid of cat and we'll run grep directly on the file. Let's see how long that takes Okay, so the original is 4.2. This is around 3.2 So that's about a second less I think if you ran it a couple more times it would be, you know, still around three seconds I ran it a little beforehand and I think the average was close to three seconds whereas This was closer to four. So basically running cat in terms of efficiency is, you know, 33% more time Okay, that's an annoyance and let me show you Now distro tube does say you can grep with awk So if you're just avoiding programs, you shouldn't use grep either, but that's not what I care about. I care about efficiency So let's see how long it takes. Let's awk This file and you know, we're grepping with awk here and we'll send that to dev know I don't know how to silence the output off the top. Well, you could add extra options to awk. I guess We'll see how this works So you'll see here. This is closer to four seconds It looks actually that awk happened to be faster than catting But it is still not close to as good as grep actually just to compare apples to apples. Let's Let's grep this to dev know. I don't think it'll actually make a difference, but you know, whatever That's what we did with awk. So that's what we should do with grep See how long mistakes Yep, so this is actually under a little bit You can see that they're comparable if we grep directly on a file a thousand times it takes three seconds If we do something silly like awk it or you know grep via awk or You know cat into grep it takes a full second more and again that's 33 percent more and You know, we're talking about again. This is a minor optimization I wasn't trying to say that if you run scripts with cat catting into grep It's into the world, but this is one of the things you have to keep your mind on Now the same thing applies to using awk. This is why you grep with grep and not awk Awk is a lot less efficient. Awk is a very nice program It does lots of great things and disertube shows some of the things that it can do Same thing is true of said, but it is not if you just want to grep something do not awk It's silly and I will say there's one other thing that he mentions in this video I sort of skipped through it And it's a meme on my channel and I want to be sure that this is not minimalism. This is me minimalism Okay, some people based on a meme in my channel will do this said 11 Q a file instead of running head on it Okay, or a capital Q whatever and The idea is this is built on the same idea. Oh, well if you want to avoid files You can just said 11 Q basic, you know set 11 Q basically says when you get to 11 quit and don't print anything out Okay Now you should use head instead of said 11 Q realistically speaking because I mean you can do the time Yourself and you'll see pretty much every time that said 11 Q is going to be it's a bigger program It it takes longer pretty much all the time now It's a very small amount here, but if you run a bajillion of times, let's do it Let's go back up here. We'll say said 11 Q on config I'll put it to dev null so we don't have to see it see how long that takes Taking a little bit of time that takes look at that took three seconds now. Let's run head on config send it to dev null See what happens that to see that took less than a second said 11 Q is incredibly stupid But but but but but there are times where you want to keep in mind the fact that you can run said 11 Q Or that you can grab with awk and that is if you're already running a awk command You know if you're already doing something and I get out of this if you're already running some kind of awk command You might as well if you're gonna grep into that awk command You might as well grep with awk if you're already running awk for something you might as well do that Same thing with said 11 Q don't read don't run said 11 Q in a script. It's just a meme It's a joke on my channel. Don't do it But if you're already running set on a file and you want some equivalent of head you might as well You know tell it to quit after a certain number of lines, you know quit after 20 lines or something like that So anyway, this is just a minor again. I just I just wanted to be clear I know some things on this channel are memes. They're very funny. We laugh at them But the recommendations I gave in telling people not to cat and to grep That's a serious thing. It's a big waste to run a next-door program Even if it's a small program on something it makes your scripts a lot I want you to be mindful of the scripts you're writing and think about efficiency at all times and efficiency often is Avoiding using programs that are less efficient like awk that again can do more things and using programs like grep that again Do one thing and do one thing only and they do it well and they do it efficiently They're written to be that way. Awk has a bunch of other stuff. You don't need it Anyway, that's about it. I'll see you guys next time. Just wanted to make that stuff clear