1 00:00:00,000 --> 00:00:02,170 [No audio] 2 00:00:02,170 --> 00:00:05,238 We're going to compare two files, how that is done? 3 00:00:05,324 --> 00:00:08,130 There are two very basic commands 4 00:00:08,450 --> 00:00:10,650 that are used in Linux. 5 00:00:10,970 --> 00:00:13,674 First one is the diff which is going 6 00:00:13,712 --> 00:00:16,782 to compare two files line by line. 7 00:00:16,916 --> 00:00:19,510 And the second one is cmp, compare 8 00:00:19,570 --> 00:00:22,390 and it does byte by byte. 9 00:00:22,570 --> 00:00:24,810 We're going to look at these two 10 00:00:24,860 --> 00:00:27,222 commands by logging into our system. 11 00:00:27,416 --> 00:00:29,190 We'll use a PuTTY session. 12 00:00:29,810 --> 00:00:34,494 And if you remember, for the PuTTY session, we 13 00:00:34,532 --> 00:00:38,050 would need the IP address of our machine. 14 00:00:38,170 --> 00:00:40,878 If you don't remember the IP address, you could 15 00:00:40,904 --> 00:00:45,177 go back into your console, 16 00:00:45,177 --> 00:00:46,579 you log in, 17 00:00:46,579 --> 00:00:49,440 [No audio] 18 00:00:49,440 --> 00:00:50,859 and you do, 19 00:00:51,570 --> 00:00:55,342 you do ifconfig, pipe it more because we 20 00:00:55,356 --> 00:00:57,790 don't want to see the information going too fast. 21 00:00:57,840 --> 00:00:59,878 So I'm piping it to more, and 22 00:00:59,904 --> 00:01:02,038 you'll see the IP addresses right here. 23 00:01:02,064 --> 00:01:03,722 You could put that IP address in your PuTTY, 24 00:01:03,746 --> 00:01:05,422 and you will be able to connect to it. 25 00:01:05,495 --> 00:01:09,360 So let's minimize this and let's see who we are. 26 00:01:09,870 --> 00:01:14,458 Sorry, whoami, which directory I'm in? 27 00:01:14,484 --> 00:01:15,420 I'm in home. 28 00:01:15,750 --> 00:01:17,450 Do what's inside my directory. 29 00:01:17,510 --> 00:01:19,622 I want to go into the directory 30 00:01:19,706 --> 00:01:23,950 superman, and see what's inside in superman. 31 00:01:23,950 --> 00:01:25,401 I have, 32 00:01:25,890 --> 00:01:28,478 I want to remove this file I created earlier. 33 00:01:28,514 --> 00:01:29,798 So this way it will be easier 34 00:01:29,834 --> 00:01:31,786 for you to understand and recreate it. 35 00:01:31,908 --> 00:01:32,993 So I'll remove it. 36 00:01:32,993 --> 00:01:33,993 So, 37 00:01:35,130 --> 00:01:37,906 okay, so I am in this directory home, 38 00:01:37,906 --> 00:01:39,682 I have also superman, and I want you 39 00:01:39,696 --> 00:01:44,270 to create a file called superman-characters. 40 00:01:44,330 --> 00:01:47,950 So let's do touch, sorry, not touch, echo, 41 00:01:49,470 --> 00:01:53,290 and the first character, clark kent 42 00:01:54,390 --> 00:01:59,697 and put it into superman-characters. 43 00:02:01,350 --> 00:02:02,842 Verify it's there. 44 00:02:03,036 --> 00:02:04,162 Yes, it's there. 45 00:02:04,296 --> 00:02:05,789 And then echo, 46 00:02:05,789 --> 00:02:11,678 [No audio] 47 00:02:11,678 --> 00:02:12,963 lois lane, 48 00:02:12,963 --> 00:02:14,965 [No audio] 49 00:02:14,965 --> 00:02:19,037 double superman-characters, 50 00:02:19,037 --> 00:02:24,025 echo, and General Zod, 51 00:02:24,025 --> 00:02:26,445 [No audio] 52 00:02:26,445 --> 00:02:29,096 superman-characters. Let's do cat, 53 00:02:29,096 --> 00:02:30,874 and you'll see it has three lines, 54 00:02:30,922 --> 00:02:33,106 clark, lois lane, and General Zod. 55 00:02:33,238 --> 00:02:35,274 I want you to create another 56 00:02:35,372 --> 00:02:39,342 file, call it superman-characters2. 57 00:02:39,416 --> 00:02:43,794 So up arrow key, go back to your first file, and this 58 00:02:43,832 --> 00:02:47,874 time I want you to do same thing, and do character2. 59 00:02:48,032 --> 00:02:51,594 Hit enter, then you will do the same thing. 60 00:02:51,752 --> 00:02:54,020 General Zod, 2. 61 00:02:54,020 --> 00:02:55,970 [No audio] 62 00:02:55,970 --> 00:02:57,930 Now, I know it was lois lane. Yes. 63 00:02:58,040 --> 00:03:00,258 So lois lane, character2, and 64 00:03:00,284 --> 00:03:04,474 the last one is General Zod. 65 00:03:04,522 --> 00:03:06,358 But this time I don't want you to do General Zod, 66 00:03:06,394 --> 00:03:11,154 I want you to do General Peter, and enter. 67 00:03:11,312 --> 00:03:13,640 Let's check the superman-characters2. 68 00:03:14,030 --> 00:03:16,402 Okay, you see the superman-characters2 has General, 69 00:03:16,426 --> 00:03:20,518 Peter, and the superman-characters has General Zod. 70 00:03:20,614 --> 00:03:21,886 Now let's do comparison. 71 00:03:21,958 --> 00:03:23,058 If you want to compare two 72 00:03:23,084 --> 00:03:24,498 files, we'll do the first one, 73 00:03:24,524 --> 00:03:27,907 we do diff and superman-characters 74 00:03:27,907 --> 00:03:29,694 with superman-characters2. 75 00:03:29,792 --> 00:03:33,222 It's going to tell you the first file right here has 76 00:03:33,356 --> 00:03:36,718 the General Zod on it and second one has General Peter. 77 00:03:36,814 --> 00:03:41,934 Now what if I compare it, superman-characters, superman-characters2. Again, 78 00:03:41,972 --> 00:03:44,682 you could do just tab and autocomplete and 79 00:03:44,696 --> 00:03:46,302 it'll tell you the last 3 lines, the 80 00:03:46,316 --> 00:03:48,318 30 bytes, and that's about the difference. 81 00:03:48,464 --> 00:03:51,678 So that's about the two commands that we 82 00:03:51,704 --> 00:03:53,850 use in Linux to compare two files. 83 00:03:54,710 --> 00:03:56,934 There is not an easy way 84 00:03:56,972 --> 00:03:59,434 to compare two files in Windows. 85 00:03:59,602 --> 00:04:02,610 So that's why again, this gives us a huge 86 00:04:02,660 --> 00:04:07,590 advantage to do file text manipulation in Linux. 87 00:04:08,450 --> 00:04:10,710 Again, I want you to do man 88 00:04:10,760 --> 00:04:17,226 command on both commands and cmp and 89 00:04:17,288 --> 00:04:19,807 just learn different options that are available. 90 00:04:19,807 --> 00:04:21,974 [No audio]