Home » Questions » Computers [ Ask a new question ]

How do I make "cp" in OS X not delete files?

How do I make "cp" in OS X not delete files?

Here's the best way to describe this:

Asked by: Guest | Views: 439
Total answers/comments: 4
bert [Entry]

"Don't use cp. Use rsync.

(Apple dev link.)"
bert [Entry]

"Use -i option to cp

-i Cause cp to write a prompt to the standard error output before
copying a file that would overwrite an existing file. If the
response from the standard input begins with the character `y'
or `Y', the file copy is attempted. (The -i option overrides
any previous -n option.)"
bert [Entry]

"Erics solution worked but I had to tweak syntax a little:

$ cd dirA
$ tar -cf - ./* | (cd .../dirB ; tar -xf -)"
"Erics solution worked but I had to tweak syntax a little:

$ cd dirA
$ tar -cf - ./* | (cd .../dirB ; tar -xf -)"
bert [Entry]

"I'm doing something similar with an export script. Here is the command I'm using:

cp -R demo_files/. demo

This will merge the files in demo_files with the files in demo. It shouldn't overwrite anything."