7

The man page for cp says this about the -a option:

Archive mode. Same as -RpP options. Preserves structure and attributes of files but not directory structure.

FreeBSD cp's manual does not have this caveat, although the structure of the options remains very similar, if not identical.

What does not preserving directory structure mean in this case?

1 Answer 1

3

It means that if you copy into an existing directory it will not delete existing files and subdirectories (and existing subdirectories will have their existing permissions and ownership information, even if there is a directory of the same name in the source copy). This is equivalent to the "merge" option when copying a folder in the Finder, and there is no equivalent to the replace option.

3
  • 1
    Seems to make sense, but it'd be great to have some reference to back this.
    – hmijail
    Commented Mar 20, 2022 at 22:57
  • Well what $(which cp) tells us it is from file_cmds project, which is open source: github.com/apple-oss-distributions/file_cmds
    – hym3242
    Commented May 15 at 23:33
  • I'm not sure this is the kind of thing you can really have a reference for, the question is "what does this language in the documentation, regarding something that the software does not do [presumably something someone might expect it to do and need to have explained to them that it doesn't], mean?" which is an inherently subjective question.
    – Random832
    Commented May 20 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .