Hey, and welcome back to this video.
So let's continue.
So we have seen how to copy a file from one source to another destination.
Let's quickly see some more ways to copy files and directories.
All right.
So let's quickly create two directories called as one and two.
So we have two directories now.
So let's quickly create two files as well.
So for that, we are going to use the command, which is nano.
Let's call it as file one and hit enter.
And let's say this is file one and let's quickly save it.
Come out of it.
Nano file two.
This is filed to save it.
And we have two folders or directories one and two and two files, which is file one and file two.
Perfect.
So now if I want to copy this file, which is a file one, so I'm going to type the command, CP file
one and copy it to the directory, which is one.
And this should have copied the file into the directory, which is one.
You can also verify using the command three.
So three, one.
And it entered and you can see the tree structure of the directory, which is one.
And there is a file which is a file one inside this directory.
Perfect.
And you can see the output over here as well.
Zero directories and one file inside one folder.
Okay.
So now let's say I want to copy this directory.
So let's say copy the directory to.
So before copying the directory, let's copy the file to as well into the directory which is two and
hit enter and let's type the command three two and see if there is a file and yes, there is a file.
So let me type the command tree over here and you can see there is a directory one which has a file
one there is a directory two which has a file two and here we have two files as well, which is file
one and file two.
Great.
Let me clear the screen for you now.
Let's say I want to copy the directory, which is two inside the directory one.
So this time I do not want to copy a file.
Instead I want to copy a directory for that.
I'm going to use the command CP.
So let's say copy two to copy one and hit enter.
And here you can see we got an error.
It says you are trying to copy a directory and not specify it hyphen.
Ah, so omitting the directory.
Now here, if you want to copy a directory you have to specify hyphen.
Ah then and only then you will be able to copy those directories.
And now when I hit enter, let's go inside one and see.
Or else we can also use the command tree and you can see inside the directory of one we have a directory
which is two which contains a file two and yes we already copy the file one inside the directory, one
which is already present.
Let's go inside one and see as well the same structure.
There is a file one and there is a new directory which has been copied over here, which is two.
If we go inside to and hit enter and see here, we can find the file which is file two, which is exactly
the same structure that we see over here.
So I hope you guys understood how you can copy directories recursively inside another, directories
from one source to another destination.
This is very, very handy and people many times make these mistakes while copying directories, which
you should always keep in mind.
I hope you guys understood.
Thank you.