Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloning permissions of a folder to another folder

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

like image 336
indragie Avatar asked Aug 19 '09 22:08

indragie


2 Answers

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).

like image 171
Gordon Davisson Avatar answered Oct 04 '22 18:10

Gordon Davisson


I presume you Googled and found at least:

  • chmod
  • acl

And this web page also seems to cover some important information (such as fsaclctl).

like image 45
Jonathan Leffler Avatar answered Oct 04 '22 18:10

Jonathan Leffler