Instructor: The move command, or MV command, allows us to move files and folders. In my folder here, I have a JS file, and then I have a source folder. The source folder is empty.
Let's say I want to move my index.js into the source folder. I just pass the target of the move, and then the destination. You have to pass the complete file name to the destination.
I could rename the file if I wanted here, so I do that. You see I just have a source folder in the root, and if I list out source, the index.js is in there now.
For example, if you just wanted to rename a file, let's create a file here, and then let's say I want to make AJS, BJS. I just move it to the same folder, and just pass a different file name here as the second parameter.
So I do that, then I have my BJS there. In this folder, I have the source directory. Let's say I wanted to rename that to lib. I could do that just like this. That renames the folder.
Let's say I now wanted to move everything in lib into source. I'll recreate a source folder here, and we're going to do move lib.
We'll do the asterisk so that it grabs all files and folders under this lib folder, and then I do source, like that. Let's list out lib. We see it's empty now, and then the index.js is now in source, like we want.
To copy a file, we use the copy, or CP command. Let's set up a file here, create a readme.md file. Let's copy that and put a copy in the source folder.
When we do this, we can rename it if we want. I want to keep the same name, but you do have to type out...Like with move, you have to type out the file name again.
So we do that, we can see we still have a readme.md here in the root. If we list it out, we see it there, and it should have the same contents. It does, because we just had the hello in there.
If we want to copy an entire folder and all of its sub-folders from one to another, we use the copy command. We pass the R flag, which standards for recursive.
If I want to move everything in the source folder, such as source/asterisk, a wild card to mean everything, and then let's copy everything from the source folder to the lib folder.
We do that. We should see it has those two files which are the same as are in the source folder.