Shell – How to copy or move files without being asked to overwrite

aliascpshell

What I've tried:

root@host [/home1]# cp -f hello /home3
cp: omitting directory `hello'
root@host [/home1]# cp -rf hello /home3
cp: overwrite `/home3/hello/.buildpath'? y
cp: overwrite `/home3/hello/.bash_logout'? y
cp: overwrite `/home3/hello/.project'? ^C

They always ask me whether I want to overwrite. Using mv doesn't work either. So what should I do?

Other things I tried:

root@host [/home1]# cp -rf hello /home3
cp: overwrite `/home3/hello/.buildpath'? y
cp: overwrite `/home3/hello/.bash_logout'? y
cp: overwrite `/home3/hello/.project'? ^C
root@host [/home1]# cp -force hello /home3
cp: invalid option -- 'o'
Try `cp --help' for more information.
root@host [/home1]# cp --remove-destination hello /home4
cp: omitting directory `hello'
root@host [/home1]# cp --remove-destination hello /home3
cp: omitting directory `hello'
root@host [/home1]# cp --remove-destination -r hello /home3
cp: overwrite `/home3/hello/.buildpath'? ^C
root@host [/home1]#

Best Answer

cp appears to be either aliased to something which is causing problems, or it is a function. You can remove the alias/function:

unalias cp
unset -f cp

If you'd rather just override it right now, you can use the command command to override any alias/function definitions:

command cp [...]

If you'd rather totally remove this, you probably have to look in your bash startup files.

Related Question