1 00:00:00,000 --> 00:00:02,049 [No audio] 2 00:00:02,049 --> 00:00:07,050 Next topic we have is combining and splitting files. 3 00:00:07,670 --> 00:00:11,480 You could combine multiple files into one 4 00:00:12,650 --> 00:00:15,522 and you could combine one file, you 5 00:00:15,536 --> 00:00:18,526 could split one file into multiple files. 6 00:00:18,718 --> 00:00:20,634 Like just an example right here. 7 00:00:20,732 --> 00:00:26,890 When you cated three files, you could output 8 00:00:26,950 --> 00:00:29,446 of all those files into a fourth file, 9 00:00:29,578 --> 00:00:31,398 which is you call it file4. 10 00:00:31,484 --> 00:00:35,610 So what will happen is whatever is inside, whatever the 11 00:00:35,660 --> 00:00:39,258 contents of those files, one, two, three, they will be 12 00:00:39,284 --> 00:00:44,802 combined and they will be pushed out toward file4. 13 00:00:44,996 --> 00:00:46,662 So that's how you combine it. 14 00:00:46,796 --> 00:00:49,842 So how do you split it and why do we need to split it? 15 00:00:50,036 --> 00:00:53,778 Okay, well, there are certain times when you do have big, 16 00:00:53,864 --> 00:00:59,046 huge files and you do need to either compress it. 17 00:00:59,228 --> 00:01:02,298 If the compressing is not an option, then what 18 00:01:02,324 --> 00:01:03,918 you could do is you could split it. 19 00:01:03,944 --> 00:01:07,726 Meaning you chop that file into different files. 20 00:01:07,918 --> 00:01:11,754 And the reason you do that is because sometimes you have 21 00:01:11,792 --> 00:01:16,098 to send files across one computer to another or to a 22 00:01:16,124 --> 00:01:19,494 third party vendor, or if it's a log file that they 23 00:01:19,532 --> 00:01:23,240 have to check, they have to check and it's huge. 24 00:01:24,110 --> 00:01:25,410 And it's huge. 25 00:01:25,580 --> 00:01:28,734 So the only way to do, and your 26 00:01:28,772 --> 00:01:31,966 only friend is out there is the split. 27 00:01:32,038 --> 00:01:34,522 So you split it, chop it, whichever the number of files 28 00:01:34,546 --> 00:01:36,918 that you want to do and boom, you will have it. 29 00:01:37,064 --> 00:01:38,958 So let's look at this file that we 30 00:01:38,984 --> 00:01:41,650 have and we will create some files. 31 00:01:41,710 --> 00:01:44,326 And in this example, you see I have a file 32 00:01:44,458 --> 00:01:49,186 and I'm splitting the file in 300 lines per file 33 00:01:49,258 --> 00:01:52,290 and putting it into a file called childfile. 34 00:01:52,850 --> 00:01:54,882 Let's look at our Linux machine and I 35 00:01:54,896 --> 00:01:57,198 will explain it to you much better while 36 00:01:57,224 --> 00:01:59,180 we are doing it through the command line. 37 00:01:59,180 --> 00:02:04,950 [No audio] 38 00:02:04,950 --> 00:02:07,894 Okay, this is our Linux terminal, which 39 00:02:07,932 --> 00:02:11,094 you guys are very familiar with. 40 00:02:11,484 --> 00:02:13,437 Okay, we are in our home directory, just confirmed that. 41 00:02:13,464 --> 00:02:16,658 So we don't have to put all the practice files 42 00:02:16,754 --> 00:02:20,342 or the stuffs that are not belong to other directories. 43 00:02:20,486 --> 00:02:23,330 So we know we are in the right directory. 44 00:02:23,510 --> 00:02:26,774 Now I want you to create a file, 45 00:02:26,942 --> 00:02:28,043 let's call it, 46 00:02:28,043 --> 00:02:30,812 [No audio] 47 00:02:30,812 --> 00:02:34,183 countries, or you know continents. 48 00:02:34,183 --> 00:02:36,377 [No audio] 49 00:02:36,377 --> 00:02:38,680 Let's call it countries That's fine. 50 00:02:38,680 --> 00:02:41,390 [Author typing] 51 00:02:41,390 --> 00:02:46,426 The file is created and I am using vi 52 00:02:46,618 --> 00:02:51,634 So the first line I'm going to create is England. 53 00:02:51,742 --> 00:02:53,060 This is just a country. 54 00:02:53,630 --> 00:03:01,926 Second one is USA, third one is Canada and so on. 55 00:03:02,048 --> 00:03:05,814 But if you don't know how to use VI at 56 00:03:05,852 --> 00:03:08,934 this point, you will be learning VI later on. 57 00:03:08,972 --> 00:03:10,926 But if you don't know how to use VI at 58 00:03:10,928 --> 00:03:13,546 this point so what you could do is echo. 59 00:03:13,678 --> 00:03:18,306 Let's remove the countries file, then do echo, put 60 00:03:18,368 --> 00:03:24,320 usa into countries, cat it and you will see. 61 00:03:24,950 --> 00:03:26,382 Yes, it's there. 62 00:03:26,576 --> 00:03:31,782 Next one you put an echo uk and 63 00:03:31,856 --> 00:03:38,279 you output with two redirects, to 64 00:03:38,279 --> 00:03:41,283 [No audio] 65 00:03:41,283 --> 00:03:43,680 countries. Make sure it's there. 66 00:03:44,370 --> 00:03:46,090 Yes, we have two countries. 67 00:03:46,770 --> 00:03:51,286 We will keep doing that until we have some text in it. 68 00:03:51,408 --> 00:03:53,830 So uk, uae, 69 00:03:53,830 --> 00:03:59,591 [No audio] 70 00:03:59,591 --> 00:04:02,661 and canada and 71 00:04:02,661 --> 00:04:04,661 [No audio] 72 00:04:04,661 --> 00:04:05,661 and 73 00:04:05,661 --> 00:04:08,114 [Author typing] 74 00:04:08,114 --> 00:04:10,901 france, and 75 00:04:10,901 --> 00:04:15,150 [Author typing] 76 00:04:15,150 --> 00:04:20,230 switzerland, and we'll stop here, japan. 77 00:04:20,910 --> 00:04:22,462 So just do that, 78 00:04:22,656 --> 00:04:28,197 confirm, that you have all those contents in there. 79 00:04:28,344 --> 00:04:31,140 So right now, how many lines do we have? 80 00:04:31,140 --> 00:04:32,641 We'll do, 81 00:04:33,370 --> 00:04:34,600 we have 7. 82 00:04:35,050 --> 00:04:42,408 So I'm going to make, split them, into split, 83 00:04:42,534 --> 00:04:46,310 and just check the option is -l, 84 00:04:46,360 --> 00:04:53,498 I'm going to split two lines each of countries, and 85 00:04:53,524 --> 00:04:57,354 I'm gonna put them in a file called separate, 86 00:04:57,402 --> 00:04:58,446 just sep, 87 00:04:58,638 --> 00:05:00,220 and I'm going to hit enter. 88 00:05:00,730 --> 00:05:02,680 Now let's see what we have. 89 00:05:04,210 --> 00:05:07,814 So you see, automatically Linux knows that once 90 00:05:07,852 --> 00:05:10,286 I'm going to create file sep, of course 91 00:05:10,348 --> 00:05:13,362 I requested to create two in each file, 92 00:05:13,446 --> 00:05:20,930 it has automatically appended with names like a, a, a, ab, ac, ad. 93 00:05:21,670 --> 00:05:25,730 So let's look at what's in our aa file. 94 00:05:26,890 --> 00:05:29,993 We have usa and uk, bb 95 00:05:29,993 --> 00:05:33,913 [No audio] 96 00:05:33,913 --> 00:05:35,331 sorry ab, 97 00:05:35,331 --> 00:05:37,232 [No audio] 98 00:05:37,300 --> 00:05:39,002 uae and canada, 99 00:05:40,475 --> 00:05:43,495 ac france and switzerland, 100 00:05:43,894 --> 00:05:46,950 and the last one is japan. 101 00:05:47,390 --> 00:05:50,374 Okay, so every file has two entries. 102 00:05:50,542 --> 00:05:54,570 Why we don't have two entries in the last file? 103 00:05:54,950 --> 00:05:57,436 Think about it. I'm going to give you a couple of seconds. 104 00:05:57,436 --> 00:06:00,873 [No audio] 105 00:06:00,873 --> 00:06:07,116 Okay, I hope you guessed it right because, we do not have,if you go 106 00:06:07,116 --> 00:06:11,230 to countries file, we do not have the exact numbers. 107 00:06:11,340 --> 00:06:14,534 Meaning we do not have eight lines. 108 00:06:14,642 --> 00:06:17,038 So that's why it took the first two put it in 109 00:06:17,064 --> 00:06:20,638 one, first two second file, first two third file, and since 110 00:06:20,664 --> 00:06:24,038 we didn't have anyone, japan was the only one left alone, 111 00:06:24,194 --> 00:06:25,394 sorry, japan, 112 00:06:25,562 --> 00:06:30,878 and that's why it went just into one line to that file. 113 00:06:31,034 --> 00:06:34,500 That's how combining file and splitting files work. 114 00:06:35,190 --> 00:06:38,038 This is a helpful tool when you have 115 00:06:38,064 --> 00:06:41,542 to split large, long, huge files, and you 116 00:06:41,556 --> 00:06:44,726 have to transfer from one computer to another. 117 00:06:44,726 --> 00:06:46,272 [No audio]