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?

link|improve this question
feedback

2 Answers

up vote 6 down vote accepted

Try the cp -n 'noclobber' option.

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

link|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
feedback

The -n option should not overwrite an existing file.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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