CP command
Format: CP [option] source file or directory destination file or directory
Option Description:-B with the same name, to prepare the original file
-F Force overwrite file with same name
-R to keep the original directory structure in a recursive way copy files
Cp-r/tmp/a/root/a
Cases
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
Copying files does not prompt
# VI ~/.BASHRC
If you see something like this, the following commands are executed with an alias, which means that the-I parameter is automatically added
Alias rm= ' Rm-i '
Alias cp= ' Cp-i '
Alias mv= ' Mv-i '
In order to copy and move a large number of files to cover the target, there will be no prompts, the command should write
# cp-rf/home/huzs.net/*/www/huzs.net/
Note that the CP command is added, meaning that it is not allowed to run with the alias in ~/.BASHRC, that is, the-i parameter
CP command
Function: Copy the given file or directory to another file or directory, just like the Copy command under DOS, the function is very powerful.
Syntax: CP [option] source file or directory destination file or directory
Description: This command copies the specified source files to the destination file or copies multiple source files to the destination directory.