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!