 A couple of days ago Archrelease Pac-Man 6.0 and during that whole fiasco one of the things you might have had to do was compare files and that's not something that I'd ever really had to do on Linux before at least on a grand scale and I didn't really know how to go about it and so I looked it up and there are actually a few different ways of doing this. Now today what I thought I'd do is cover two different ways you can compare files on Linux. The first one is called Diff and before we jump into Diff I just want to say really Diff is for smaller files at least in my experience which is just not a large amount of experience because I just started using this a couple of days ago but it seems to me that if you are trying to compare much larger files the efficiency or the efficacy of Diff would go down because you'll see it just wouldn't be easy to go through and parse that many differences in a larger amount of data. So let's go ahead and jump into Diff and then after that I'm going to be talking about meld which is a GUI application which is going to be much better for larger files so let's go ahead and jump in. So the first thing we need to do is find two files that we want to compare and I'm just going to use the files that I compared for the Pac-Man 6.0 fiasco and those files are in the Etsy folder so if we do an LS here we'll actually see two Pac-Man .com files this one here and this one here and what we want to do is compare them and we can do that using the Diff command so we'll do Diff Pac-Man .conf and Pac-Man .conf.pacnew and then we just hit enter. Now let me zoom in here a little bit. What we'll actually do is run that again so that we can actually see. The question it becomes how do you read the output of this file and that's where it gets a little tricky so there are certain ways that you read these codes and it's really is kind of like deciphering codes so what does 5 comma 6 D4 mean? So those numbers at the beginning refer to the first file always the first file so in this case it's Pac-Man .conf the number after the letter always refers to the second file so in this case Pac-Man .conf .pacnew. The letter in between changes as you can see we got a D we got a C there's another C you might also find an A here somewhere but I don't have an A so I can't show you that. The question is what do those mean so D in this situation means deleted so that means lines 5 and 6 need to be deleted from the first file in order to match the second file which is on line 4 so that means that these two lines here have to be removed from the first file in order to make match the second file it's like I said this is not the easiest thing to decipher because it's I mean it looks weird right and it's kind of complicated so the letter C means that the line in the first file needs to be changed to match the file line in the second file so what this means is we need to change line 33 or the 35 in the first file to match the second file which is on line 33 again it's really confusing and down here we have another deletion so line 37 which needs to be deleted to match line 34 which is so it'd be exactly the same so the question becomes then what's the comma means so basically if you use them you'll know that this means a range so this means line 39 through line 41 in order to get those to match lines 36 to 37 we need to add these lines here or take them out you know it depends on which way you're going right the next thing you have to know is what these greater than or left less than signs are so this greater line here is always referring to the first file the less than sign or this other sign here I guess I always get those mixed up refers to the second file so if you're thinking this is super super complicated and why would you ever do this I'm with you like I just think I went through and explain this and everybody's probably like Matt that was the most confusing thing and then the people who know how to use differ like what are you talking about that's not how it works so when I first was looking at the how do I go through and compare files this is what I came up with like you know I kind of understand it like I'm looking at a tutorial and it shows you how things are doing like I understand like lines five and six in line one would need to be deleted in order to match the second file okay I I'm pretty sure that that's what that means according to the tutorial that's what that means and the C's down the C one that means that we need to change these lines in the first file in order to match the second file or maybe it's the other way around I don't like it's very confusing right like I don't know so that's where meld comes in so if you can figure out what diff means more power to you and I hope that the the horrible explanation I just had and I will link a better much better tutorial in the video description it will at least make a little bit more sense than what I did if you can't figure this out let's look at meld because meld is much better so what we want to do is you can do this from you can open meld up in a from your menu system whatever you want to do I'm going to open up from the terminal because it's easier I'm gonna do meld and then I'm going to do the same two files as I did before and then we'll make this full-screen and then I think I can zoom in here that way you can actually see okay good alright but anyways as you can see this is actually much better so as you can see on the left hand side we have pac-man.com on the right hand side we have pac-man.com.pacnew and what meld will do I'll actually go through and highlight the differences so this line here exists in pac-man.com this line here or in in this file here it doesn't exist and here we have color now we can we see what diff was talking about earlier so if we go back up here to diff we can see that those two lines that were highlighted in meld just a second ago exist in the first file and not in the second file so that's why it wants you to delete them in order to get them to be the same and the same thing with color here we have one that is uncommented we have one that is commented so if we go back here we have these two differences here okay and that's the basically what it's saying is that it needs you to change one of the other that's why it's there's a space in between here and we have this this symbol here referring to both files the line here is exactly the same just there's that one difference okay and the same thing here with this here we cannot check this space from within the true environment you know this exists in one and not in the other and same thing here now you'll notice the different colors when something doesn't exist in one file another it's green when there's just a slight difference between them make the line exists but there's a difference so in this case some are uncommented some are commented then the color is blue and those are the only changes or the only differences in these files now if we go back to diff the same thing here is we know that this line here because it says D doesn't exist in the first file because it shows us this here and we know that these lines here because it uses the letter C exist in the both files but they're different and that's just showing you the difference between them so that is diff and meld now what I think if you noticed is that once I opened up meld it was much easier to actually understand what the hell diff was talking about so the way I see it is always start with meld meld is a great program it's something that a lot of people use and I normally kind of shy away from GUIs because I prefer to use terminal based applications but in this case actually being able to see the differences not have to deal with really weird symbols and syntax and stuff like that I mean at first at least you know this is better right actually seeing the difference is is better but also because you've started on this because now I've you know looked at this I can understand the output of diff way better than I could before I looked at meld so in this case I think it's a really it's a really good example of how a GUI application can kind of show you how certain Linux commands actually work in a more visual way and can kind of lead you to actually learning more so for me personally I probably will always use meld because when I need to do this I actually want to see those differences but if you're just comparing a very two very short files diff probably would do you just fine as long as you can understand what it means which I'm not saying that I always can I obviously always can't I mean that's not the way you say it but I don't care that's just you know the output can be very confusing when you use diff and so these two different methods kind of lose their meld is always going to be superior especially when you have a ton of changes because you don't want to actually have to go through all that diff stuff if you have you know 30 or 40 differences between the files right you know it's really good if there's just two or three differences which is was the case here or at least it can be really good if you can understand the output so that is it for me today if you understand how to use diff make sure you leave a comment below goodness knows you're probably one of the only ones so I'll also leave a link for both diff and meld in the video description below make sure you check them out you can follow me on Twitter at the Linuxcast you can support me on patreon.patreon.com slash Linuxcast before I go I'd like to take a moment to thank our current patrons Devon Marcus Magland Donnie Sven East Coast Web Merrick Camp and Mitchell thanks everybody for watching I'll see you next time