I'm curious. As far as cp and rsync I see all these different options. Correct me if I'm wrong, but if you copy + paste in Finder, lets say from one hard drive to another, it should preserve:

  • All file attributes (access time, modified time etc.)

  • All Symbolic Links

  • Recurse through the directory structure

  • (Can't think of anything else to preserve)?

So in the end, when you copy paste in Finder, everything will be an exact copy, just located in a different parent directory.

What I'm looking for is a command that mimics exactly what Finder does when you copy + paste. That will answer this question...

If it turns out Finder doesn't do what I think it does please explain, and show the command line equivalents for what Finder actually does... it must be calling a command when you use the GUI - right?

  • What you need is the ditto command that does exactly the same as copy files in Finder. See man ditto for additional information.
    – dante12
    Feb 26 '17 at 21:40

If you want to preserve file attributes, symbolic links, and recursive structure, rsync should suffice:

rsync -a ~/somefolder /Volumes/SomeUSB/

The -a (archive) flag is a shortcut for the following rsync options:

--recursive recurse into directories
--links copy symlinks as symlinks
--perms preserve permissions
--times preserve times
--group sets the group of the destination file to be the same as the source file
--owner sets the owner of the destination file to be the same as the source file (if you're copying to a remote system, the remote SSH user will need to have superuser status for this)
--devices rsync will transfer character and block device files to the remote system.

You must log in to answer this question.

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