This article mainly introduces the difference between the parameter r and R of cp in linux. In daily operation, I believe that many people have doubts about the difference between the parameter r and R of cp in linux. Formula information, sort out simple and easy-to-use operation methods, I hope it will help you to answer the doubts about the difference between the parameters r and R of cp in linux! Next, please follow the editor to learn together!
Differences: 1. cp -r copies both the files in the current directory and the folders in the current directory, while cp -R only copies in the current directory 2. cp -r folders with files will overwrite folders with the same name without files, and files will also be overwritten, while cp -R will not overwrite folders with content. But it will overwrite the empty file with the same name; 3. cp -r does not use the file suffix name as the identification basis, but cp -R uses the file suffix name as the identification basis.
The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
The difference between cp -r and -R of the LINUX command is: different copying, different coverage, and different identification basis.
1. Copy different
cp -r: cp -r copies the files in the current directory, Also copies folders under the current directory.
-R: -R only copies the files in the current directory, not the folders in the current directory.
Second, coverage is different
cp -r: cp -r contains files A folder with the same name will overwrite a folder with the same name that does not contain a file, and the file will also be overwritten.
-R: -R will not overwrite folders with content, but will overwrite empty files with the same name.
Third, the identification basis is different
cp -r: cp -r does not use files The suffix name is used as the identification basis.
-R: -R uses the file extension as the basis for identification.
Example:
Extension:
Linux cp (English spelling: copy file) command is mainly used to copy files or directories.
Syntax
cp [options] source dest
or
cp [options] source... directory
Parameter description:
-a: This option is usually used when copying directories, it preserves links, file attributes, and copies all content under the directory. Its effect is equal to the combination of dpR parameters.
-d: Keep the link when copying. The link mentioned here is equivalent to the shortcut in Windows system.
-f: Overwrite existing target files without prompting.
-i: Contrary to the -f option, a prompt is given before overwriting the target file, asking the user to confirm whether to overwrite, and the target file will be overwritten when answering y.
-p: In addition to copying the content of the file, the modification time and access rights are also copied to the new file.
-r: If the given source file is a directory file, all subdirectories and files under the directory will be copied.
-l: Do not copy files, just generate link files.
Copyright Description:No reproduction without permission。
Knowledge sharing community for developers。
Let more developers benefit from it。
Help developers share knowledge through the Internet。
Follow us