Name: CP
Use Rights: All users
How to use:
CP [Options] Source Dest
CP [options] source ... directory
Note: Copy one file to another file or copy several files to another directory.
-A,--archive equals-dr--preserve=all
--backup[=control Create a backup for each existing target file
-B is similar to--backup but does not accept parameters
--copy-contents in recursive processing is the copying of special file contents
-D equals--no-dereference--preserve=links
-F,--force remove the target file if it cannot be opened and try again (when-n option
Does not need to be selected when it is present
-I,--interactive before overwriting (invalidates the previous-n option)
-H follow the command line symbolic link in the source file
-L,--link linked file without copying
-L,--dereference always follow symbolic links
-N,--no-clobber do not overwrite existing files (make the previous-I option invalid)
-P,--no-dereference does not follow symbolic links in source files
-P equals--preserve= mode, ownership, timestamp
The--preserve[= property list retains the specified property (default: Mode, ownership, timestamp), if
May retain additional properties: environment, links, xattr, etc.
-R, R,--recursive copy all items in directory and directory
Example:
Copying files, copying files only if the source file is newer than the destination file's modification time
Cp-u-V file1 file2
. copy file file1 to file File2
CP file1 File2
. interactively copy file file1 into a file file2
Cp-i file1 file2
Copy the file file1 to File2 because the destination file already exists, so specify the mode to use forced replication
Cp-f file1 file2
. copy directory Dir1 into a directory Dir2
Cp-r file1 file2
. Also copy files File1, file2, File3, and directory Dir1 to Dir2
Cp-r file1 file2 file3 dir1 dir2
. preserve file properties when copying
Cp-p a.txt tmp/
. Preserve the directory structure of files when replicating
Cp-p/var/tmp/a.txt./temp/
. Generate backup files when replicating
Cp-b a.txt tmp/
The backup file is generated when copying, and the tail-label ~1~ format
Cp-b-V T a.txt/tmp
. Specify the tail label of the backup file
Cp-b-S _bak a.txt/tmp