Cp -recurse Appendix A command line crash course

what is the function of this command in page 317?
i can see it creates a “new name” for the old file
lets say: old file is called : “something”
so i run the command
cp -recurse something newplace(name of the new file)
it changed the name of the old file for the new one, and copied its content.
that is the function of cp-r?

Hello.

The command: “cp -r” is used when copying folders and it means that when you are copying a folder anything inside it also is copied.

If you want to place the copy of a file or folder in the same folder as you are at the moment you have to give it a new name.

cp text_file1.txt text_file2.txt
or
cp -r folder_1 folder_2

If you copy a file to another location you can get away with the same name as it currently have.

cp more.txt folder_1/

This will paste more.txt into folder_1 with the same name (more.txt).

Hope this clarifying a little bit.

1 Like
A free service run by Zed A. Shaw for learncodethehardway.org.