Next topic we have is combining and splitting files, you could combine multiple files into one and
you could combine one file so you could split one file into multiple files, like just an example right
here.
And you can it four or three files.
You can output the cat output of all those files into a fourth file, which, as you call it, filed
for.
So what will happen is whatever is inside, whatever the contents of those files, one, two or three,
they will be combined and they will be pushed out to work file for.
So that's how you combine it.
So how do you split it and why do we need to split it?
OK, well, there are certain times when you do have big, huge files and you do need to either compress
it.
If the compressing is not an option, then what you could do is you could split it, meaning you chop
that file into different files.
And the reason you do that is because sometimes you have to send files across one computer to another
or to a third party lender, or if it's a log file that they have to check, they have to check.
And it's huge and it's huge.
So the only way to do and your only friend is out there is the split.
So you split it, chop it, whichever the number of files that you want to do and boom, you will have
it.
So let's look at this file that we have and we will create some files.
And in this example, you see I have a file and I'm splitting the file in 300 lines prior file and putting
it into a file called a child file.
Let's look at our Linux machine and I will explain it to you much better while we are doing it through
the command line.
OK, this is our Linux terminal, which you guys are very familiar with.
OK, we are in our home directory.
Just confirmed that.
So we don't have to put all the practice files or the stuffs that are not belong to other directories.
So we know we are in the right direction.
Now, I want you to create a file.
Let's call that.
Countries are, you know, continents or.
That's called country, that's fine,
the file is created and I am using V.I., so the first line I'm going to create is England.
This is just a country.
Second one is USA, third one is Canada and so on.
But if you don't know how to use VI at this point, you will be learning why later on.
But if you don't know how to use VI at this point, so what you could do is echo this, remove the country's
file, then do echo put USA into countries cadart and you will see, yes, it's their next one.
You put an echo UK and you output.
But to redirect to.
Countries make sure it's there.
Yes, we have two countries, we'll keep doing that until we have some text in it.
So U.K., UAE.
And Canada
and
France and
Switzerland, and we'll stop here, Japan, so just do that, confirm that you have all those contents
in there.
So right now, how many lines do we have?
Well, do we have seven?
So I'm going to make split them into split and just check.
The option is minus I'm going to split two lines each of countries and I'm going to put them in a file
called Separate Jessep.
And I'm going to hit enter.
Now let's see what we have.
So you see, automatically Linux knows that once I'm going to create file sep, of course, I requested
to create two in each file.
It has automatically appended with names like A, A, A, B and C a deep.
So let's look at what's in here.
A file we have USA and UK b.
B.
Sorry, Abby UAI in Canada, a sea, France and Switzerland, and the last one is Japan.
OK, so every file has two entries.
Why we don't have two entries in the last file.
Think about it.
I'm going to give you a couple of seconds.
OK, I hope you get it right, because we do not have if you go to countries file, we do not have the
exact numbers, meaning we don't have eight lines.
So that's why it took the first to put it in one first to second file, first to third file.
And since we didn't have anyone, Japan was the only one left alone sorry, Japan.
And that's why it went just into one line to that file.
That's how combining file and splatting files work.
This is a helpful tool when you have to split large, long, huge files and you have to transfer from
one computer to another.