Next topic rehab is combining and splitting files you can 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 could put the cat output of all those files into a file which
as you call it filed for.
So what will happen is whatever is inside whatever the content of those files 2:59 they will be combined
and they will be pushed out to Word 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 vendor or if it's a log file that they have to check.
They have to check and it's heyou age and it's huge.
So the only way to do and your only friend is out there is displayed 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 profile 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're doing it through the command line
OK this is our Lankes 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 directory.
Now I want you to create a file that is call that
countries or continents or
let's call countries that's fine.
The file is created and I am using vi.
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 it later on.
But if you don't know how to use vi at this point.
So what you can do is go let's remove the countries file then do go.
Put USA into countries catch it and you will see.
Yes.
It's their next one you put an echo you k and you output with to redirects to
countries make sure it's there.
Yes we have two countries.
We will keep doing that until we have some text in it.
So you k you a b
and Canada
and
France and
so and will stop here Japan so just do that confirm that you have all those content 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 mine as well.
I'm going to split two lines each of the countries and I'm going to put them in a file called Separate
just set up and I'm going to hit enter.
Now let's see what we have.
So you say automatically Linux knows that once I'm going to create files set of course I requested to
create two in each file.
It has automatically appended with names like A B A C A D.
So let's look at what's in our a file.
We have U.S. and U.K. B-B
sorry AB UK in Canada.
A C France has a LAN 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 8 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 fire and splitting 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.