[No audio]
We're going to compare two files, how that is done?
There are two very basic commands
that are used in Linux.
First one is the diff which is going
to compare two files line by line.
And the second one is cmp, compare
and it does byte by byte.
We're going to look at these two
commands by logging into our system.
We'll use a PuTTY session.
And if you remember, for the PuTTY session, we
would need the IP address of our machine.
If you don't remember the IP address, you could
go back into your console,
you log in,
[No audio]
and you do,
you do ifconfig, pipe it more because we
don't want to see the information going too fast.
So I'm piping it to more, and
you'll see the IP addresses right here.
You could put that IP address in your PuTTY,
and you will be able to connect to it.
So let's minimize this and let's see who we are.
Sorry, whoami, which directory I'm in?
I'm in home.
Do what's inside my directory.
I want to go into the directory
superman, and see what's inside in superman.
I have,
I want to remove this file I created earlier.
So this way it will be easier
for you to understand and recreate it.
So I'll remove it.
So,
okay, so I am in this directory home,
I have also superman, and I want you
to create a file called superman-characters.
So let's do touch, sorry, not touch, echo,
and the first character, clark kent
and put it into superman-characters.
Verify it's there.
Yes, it's there.
And then echo,
[No audio]
lois lane,
[No audio]
double superman-characters,
echo, and General Zod,
[No audio]
superman-characters. Let's do cat,
and you'll see it has three lines,
clark, lois lane, and General Zod.
I want you to create another
file, call it superman-characters2.
So up arrow key, go back to your first file, and this
time I want you to do same thing, and do character2.
Hit enter, then you will do the same thing.
General Zod, 2.
[No audio]
Now, I know it was lois lane. Yes.
So lois lane, character2, and
the last one is General Zod.
But this time I don't want you to do General Zod,
I want you to do General Peter, and enter.
Let's check the superman-characters2.
Okay, you see the superman-characters2 has General,
Peter, and the superman-characters has General Zod.
Now let's do comparison.
If you want to compare two
files, we'll do the first one,
we do diff and superman-characters
with superman-characters2.
It's going to tell you the first file right here has
the General Zod on it and second one has General Peter.
Now what if I compare it, superman-characters, superman-characters2. Again,
you could do just tab and autocomplete and
it'll tell you the last 3 lines, the
30 bytes, and that's about the difference.
So that's about the two commands that we
use in Linux to compare two files.
There is not an easy way
to compare two files in Windows.
So that's why again, this gives us a huge
advantage to do file text manipulation in Linux.
Again, I want you to do man
command on both commands and cmp and
just learn different options that are available.
[No audio]