Use the CP command under Linux, often prompt whether to overwrite, if is too batch of file overwrite, always so prompt, will be very annoying. So how do we solve this problem?
Let's look at the reasons first!
Generally we use the command is CP-RF sourcefile targetdir or Cp-r-F sourcefile targetdir,
-R means recursive replication, that is, copying the folder and all of its files
-F means to encounter files with the same name, without prompting, directly overwriting
But why do we use these two parameters, the system will still prompt to overwrite it?
This is because the system uses aliases when installing, which prevents us from accidentally overwriting files that should not be overwritten. You can see the specific configuration using the alias command.
[[email protected] 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 '
From the top we can see that the CP command we entered is actually the "cp-i" command,
That is, no matter how we enter CP-RF, in fact, the implementation is Cp-i-RF, it is no wonder that always asked whether the cover.
From the above command we can know that several other commands, also used aliases, such as Ll,ls mv,rm.
So how do we solve this problem?
[Email protected] 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 can comment out the command by adding the # number before the corresponding command. Save the exit and then you can use the Pure original command.
In fact, there is a way to solve this problem, is to use the \cp-f file dir on it!
How to make CP command not prompt overwrite under Linux