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: 71
Total answers/comments: 4
Guest [Entry]

"Don't use cp. Use rsync.

(Apple dev link.)"
Guest [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.)"
Guest [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 -)"
Guest [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."