When moving or copying files under linux to overwrite the same folder, each file in the folder will prompt whether to overwrite

1. This will not prompt you: # \cp -rf  
2. Reason:
# vi ~ / .bashrc
 If you see the following, the following commands will be executed with aliases, 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 overwrite the target without generating a prompt one by one, the command should be written like this
# \cp -rf /data/xxx*  /home/xxx    
Note that \ is added before the cp command, which means that it is not allowed to run with the alias in ~/.bashrc, that is, the -i parameter
3. The meaning of each option of the supplement cp command is as follows
-a This option is usually used when copying directories. It preserves links, file attributes, and recursively copies directories, and acts as a combination of dpR options.
  -d preserve links when copying.
  -f Delete existing object files without prompting.
  The -i option is the opposite of the f option and will prompt the user for confirmation before overwriting the target file. When answering y, the target file will be overwritten, which is an interactive copy.
  -p At this time, cp will not only copy the content of the source file, but also copy its modification time and access rights to the new file.
  -r If the given source file is a directory file, then cp will recursively copy all subdirectories and files in the directory. In this case the target file must be a directory name.
  - l does not make a copy, just links the file .
4. It should be noted that, in order to prevent the user from inadvertently destroying another file with the cp command, if the target file name specified by the user is an existing file name, after copying the file with the cp command, the file will be deleted. The newly copied source file is overwritten. Therefore, it is recommended that users use the i option when using the cp command to copy files.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326102886&siteId=291194637