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.

I have a list of files that I am copying around for various purposes. What my current command looks similar to this:

cat list_of_files | xargs -I {} /bin/cp -f {} /destination/dir

I am using the full path to cp so that the default alias of cp -i does not take effect. However, when I find a duplicate file, it is overwriting any that have already been copied. What I would like to do is to force cp to not overwrite and not prompt.

Is there any way to do this?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Try the cp -n 'noclobber' option.

It doesn't overwrite existing files and overrides a previous -i option.

share|improve this answer
    
you know, I read that man page 3 times, and it got past me every time. Thanks. –  Kirk Jun 17 '11 at 23:54

The -n option should not overwrite an existing file.

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.