Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I stop the cp command from prompting to overwrite. I want to overwrite all the files with out having to keep going back to the terminal. As these are large files and take some time to complete.

I tried using the -f option. It still ask if I want to overwrite.

   -f, --force
          if an existing destination file cannot be opened, remove it and
          try again (redundant if the -n option is used)

cp -f /media/somedir/somefiles* .  
cp: overwrite `./somefilesxxx'? y
share|improve this question

2 Answers 2

up vote 7 down vote accepted

In addition to calling /bin/cp, you could do one of:

\cp -f ...
command cp -f ...

However, I agree that you should not get accustomed to using an alias like cp -i or rm -i -- if you sit down at a different shell, you won't have the safety net you've become dependent on.

share|improve this answer

After seeing this solution. I could see that bashes alias feature was causing the problems. http://systembash.com/content/prompt-to-confirm-copy-even-with-cp-f/

which cp  
alias cp='cp -i'
/bin/cp
which cp | grep cp
alias cp='cp -i'
/bin/cp

He recommends

unalias cp

I still want to keep the alias I just don't want it to apply to this instance. My solution is to use the binary with a full path, so that bashes alias function does not take over. That works quite well.

/bin/cp -f /media/somedir/somefiles* .  
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.