In Mac OS X Snow Leopard, how can one file’s permissions be matched to another

filesfilesystemsosxpermissions

I need to make the permissions of a file exactly match the permissions of another file in OS X 10.6.

I don't see 'getfacl' or 'setfacl' as suggested in some other posts for Linux. And, it doesn't look like chown/chmod have a –reference option in Snow Leopard.

What is the equivalent on the Mac?

Best Answer

OK, so for a straight ACL copy, I can't see a single command. However, you can put this in a script or function:

ls -le source | sed -En '/^ [[:digit:]]+: / { s/^ [[:digit:]]+: //; p; }' | chmod -E dest

eg.

function copyacl()
{
  ls -le "$1" \
    | sed -En '/^ [[:digit:]]+: / { s/^ [[:digit:]]+: //; p; }' \
    | chmod -E "$2"
}

$ copyacl sourcefile destfile

I feel like that sed script could be improved, but it seems to do the job.

Related Question