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 a 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 catagrap when you can use ack and This oh 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 Grap so for example Catting this file config piping it into Grap to search for this sequence i3 Okay, now that works, but that is not the correct way to do it You Grap or yeah, you Grap 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 catted out a file and you want to grip it now And so you go back up and add Grap 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 awk 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 as well if you can avoid cat You can easily avoid Grap as well because you can Grap with a program like awk you can do something like this and that produces the same output now Of course Grap has extra features like you can you know highlight Whatever the match is but awk can do pretty much everything Grap 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 Graping grip is the best program to grip with said is not good for gripping either use grip for gripping 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 Example I just gave you a second ago. First let's cat the config file into i Integrep to search for 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 grab 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 1000 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 grip directly on the file. Let's see how long that takes Okay, so the original was 4.2 this is around 3.2 So that's about a second less and 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 4 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 distra tube does say you can grab with awk so if you're just avoiding programs you shouldn't use grab prior 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 devnull. 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 4 seconds. It looks actually that awk happened to be faster than catting But it is still not close to as good as grip actually just to compare apples to apples. Let's Let's grep this to devnull. 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 this takes Yep, so this is actually under a little bit So 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% 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 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 this are two 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 the my channel and I want to be sure that this is not minimalism. This is meme minimalism Okay, some people Based on a meme in my channel will do this said 11qa file instead of running head on it. Okay or 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 set 11q base you know set 11q basically says when you get to 11 quit and don't print anything out Okay Now you should use head instead of set 11q realistically speaking because I mean you can do the time Yourself and you'll see pretty much every time that set 11q is gonna be it's a bigger program It takes longer pretty much all the time Now it's a very small amount here, but if you run it a bajillion of times. Let's do it. Let's go back up here We'll say said 11q on config. I'll put it to dev null so we don't have to see it see how long that takes Take 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 set 11q is incredibly stupid But but but but but but there are times where you want to keep in mind the fact that you can run set 11q or that you can Grap with aq and that is if you're already running a aq command You know if you're already doing something and I get out of this if you're already running some kind of aq command You might as well if you're gonna grab into that aq command you might as well Grap with aq if you're already running aq for something you might as well do that same thing with set 11q Don't read don't run set 11q 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 into Grap That's a serious thing. It's a big waste to run an extra 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 aq that again can do more things and using programs like Grap 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 arc 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