How to clone/copy all file/directory attributes onto different file/directory?
After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp
-related answer.
rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir
This does:
-p, --perms preserve permissions
-t, --times preserve modification times
-o, --owner preserve owner (super-user only)
-g, --group preserve group
-d, --dirs transfer directories without recursing
-A, --acls preserve ACLs (implies --perms)
-X, --xattrs preserve extended attributes
--no-recursive disables recursion
For reference
--no-OPTION turn off an implied OPTION (e.g. --no-D)
-r, --recursive recurse into directories