Today, I copied a folder on my VPS, but there is a folder with the same name and there are files in it. if I copied it directly, there are N prompts to confirm the replacement, CTRL + C directly, searched on the Internet, and found that there are several ways to solve the problem, the method is as follows: Generally we use the command cp-rfsourcefiletargetdir or cp-r-fsourcefiletargetdir, & nbsp
Today, I copied a folder on my VPS, but there is a folder with the same name and there are files in it. if I copied it directly, there are N prompts to confirm the replacement, press CTRL + C and search for it on the internet. several solutions are available:
Generally, the command we use is cp-rf sourcefile targetdir or cp-r-f sourcefile targetdir,
-R indicates recursive replication, that is, copying a folder and all its files.
-F indicates that a file with the same name is encountered and directly overwritten without prompting
But why are we still prompted to overwrite the two parameters?
This is because the system uses aliases during installation to prevent improper operations and overwrite files that should not be overwritten. Use the alias command to view the specific configuration.
[Test @ Server home] # alias
Alias cp = 'CP-I'
Alias l. = 'ls-d. * -- color = tty'
Alias ll = 'ls-l -- color = tty'
Alias ls = 'ls -- color = tty'
Alias mv = 'MV-I'
Alias rm = 'rm-I'
Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'
We can see from the above that the cp command we entered is actually the "cp-I" command,
That is, no matter how we input cp-rf, we actually execute cp-I-rf, and it's no wonder we always ask whether to overwrite it.
We can see from the above commands that several other commands also use aliases, such as ll, ls mv, and rm.
How can this problem be solved?
[Test @ Server home] # vi ~ /. Bashrc
#. Bashrc
# User specific aliases and functions
Alias rm = 'rm-I'
Alias cp = 'CP-I'
Alias mv = 'MV-I'
# Source global definitions
If [-f/etc/bashrc]; then
./Etc/bashrc
Fi
You only need to add the # sign before the corresponding command to comment out the command. Save and exit, and then you can use pure original commands.
In fact, there is a simpler way to solve this problem, that is, add a backslash such as \ cp-f file dir before cp!