1

If I use cp in archive mode e.g

cp -a /my_old_directory/* /new_location/my_new_directory/

to replicate a directory structure and all that is in it.

If I then run the same command again will any changed files be refreshed or over-written or skipped?

(I know rsync is more advanced at this kind of thing, I'm just curious about cp -a as I can't find any description of what it actually does in this case.

1

cp will overwrite all files.

what you are looking for if you do not want that behavior is the rsync command.

the -a option just means it will preserve the source file metadata, like creation time, owner, access mode and such..

0

Existing files will be over-written, as somewhat implied in gilles' answer to Difference between cp -r and cp -a.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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