How to force cp to overwrite without confirmation
This is probably caused by cp
being already aliased to something like cp -i
. Calling cp
directly should work:
/bin/cp -rf /zzz/zzz/* /xxx/xxx
Another way to get around this is to use the yes
command:
yes | cp -rf /zzz/zzz/* /xxx/xxx
You can do yes | cp -rf xxx yyy
, but my gutfeeling says that if you do it as root - your .bashrc
or .profile
has an alias of cp
to cp -i
, most modern systems (primarily RH-derivatives) do that to root profiles.
You can check existing aliases by running alias
at the command prompt, or which cp
to check aliases only for cp
.
If you do have an alias defined, running unalias cp
will abolish that for the current session, otherwise you can just remove it from your shell profile.
You can temporarily bypass an alias and use the non-aliased version of a command by prefixing it with \
, e.g. \cp whatever