Under Linux, if you want to copy file files to directory dir, you can do this: CP file dir
However, if a file named files already exists under Dir, the system will always prompt you to overwrite it.
This is a good feature that prevents us from inadvertently causing damage to the system, but what if we don't want to see the cues for these interactions? For example, we need to write a script to install some files into the specified directory, we certainly do not want to see the prompt.
You can try the-f option, and-F generally indicates enforcement (force).
Cp-f file dir
But it seems that the result is not as we hoped, the system will still have the overlay hint. Why is it?
The reason is simple, the system will be the CP command alias Cp-i.
When we execute the CP command, the system often executes the CP-I,-I option to indicate that there are interactive prompts,
So when the cp-f is executed, the system actually executes cp-i-F, so there will still be an overlay hint.
You can perform the alias command to view the following:
Alias cp= ' cp-i ' Alias l.= ' ls-d. *--color=auto ' Alias ll= ' Ls-l--color=auto ' Alias ls= ' ls--color=auto ' alias mv= ' Mv-i ' Ali As rm= ' rm-i ' Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '
It's also easy to execute the original CP:
1. Add an absolute path (available via the whereis CP command) when calling CP, as
/bin/cp-f file dir
2. Invoke the system's original command by directly executing the following statement:
\cp-f file dir
3. Comment out Alias cp= ' cp-i ' in ~/.BASHRC
4.unalias CP, then use CP, but restore alias cp= ' cp-i ' after use
Reference:
Http://www.myexception.cn/linux-unix/446791.html
Http://www.php100.com/html/webkaifa/Linux/2010/0525/6409.html
How to make CP command not prompt overwrite file under Linux