How to copy or move files without being asked to overwrite?
Solution 1
For force overwrite without asking you should use the command mv and the option "-f", use man to see the options.
man mv:
-f, --force
do not prompt before overwriting
Example:
mv -f test.tmp test.txt
Solution 2
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.
Solution 3
You probably have an alias for cp. You can override this alias by doing:
\cp -f hello /home3
This has the adventage of not modifying your aliases setup, as it is overriding it just for this call.
Solution 4
Try cp -rv /sourcefileordirectory /Destinationfolder
Related videos on Youtube
user2935706
Updated on September 18, 2022Comments
-
user2935706 almost 2 years
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]#
-
Raphael Ahrens almost 11 yearsCould you give the output of
alias cp
? -
user almost 11 yearsAlso,
type cp
as well asls -l
on one of the target files may provide useful information. -
user2935706 almost 11 yearscp is copy. Okay it may be an alias. So what's the command?
-
-
sendmoreinfo almost 11 years
\cp
will also avoid the alias. -
user2935706 almost 11 yearswill t his work? What does -rv mean?
-
JNat over 9 years
-rv
means recursive and verbose. So this should copy the files and subfolders, and output the progress to the terminal. -
Gerry about 9 yearsYup, you are correct
which cp => alias cp='cp -i; /bin/cp
. Thanks Amazon!