Cloning permissions of a folder to another folder
acl, macos, permissions, shell
Solution
Tested on Mac OS X v10.5.7, in bash:
chown $(stat -f%u:%g "$srcdir") "$dstdir" # Copy owner and group
chmod $(stat -f%Mp%Lp "$srcdir") "$dstdir" # Copy the mode bits
(ls -lde "$srcdir" | tail +2 | sed 's/^ [0-9]*: //'; echo) | chmod -E "$dstdir" # Copy the ACL
Notes: These operations (esp. changing ownership) are likely to require root access; sprinkle with `sudo` for best results. Also, that odd `echo` command on the last line is there to prevent an error if srcdir doesn't have any ACL entries attached (`chmod -E` can cope with blank lines, but not a completely empty input).
Problem
Are there any ways in OS X to clone the permissions of one folder to another. Just to be clear, I don't want to copy the entire folder, just the permissions and then set them on another folder. I think this type of thing could be achieved on Linux/UNIX using the setfacl/getfacl commands, but I'm unsure on how to do this with OS X. Thanks