Just as it sounds, I'm trying to find out if there is a (standard) command that will produce a diff of the permissions between two files and/or directory trees.

Ideally it would put out a patch file that could be used to change permissions to match the target, though I'm guessing since standard patch files are interpreted by ed, that it might have to be a separate format.


You could always do something like this to get the differences.

diff -u <( cd path1 ; find . -printf "chown %U:%G %p; chmod %m %p \n" | sort ) \
        <( cd path2 ; find . -printf "chown %U:%G %p; chmod %m %p \n" | sort )

It would then be trivial to hack up something that performs the require changes.

  • The problem then would be that the patch script would need to be on the target system. It could all be baked into a single script, but people tend to get a little antsy about being asked to run an executable. – Catskul Jun 20 '12 at 23:43
  • 1
    Sorry, but I don't know what you are talking about. What do you mean by target system? Perhaps you need to update your question with more details about what you are doing. – Zoredache Jun 21 '12 at 0:55
  • 1
    A patch eventually has to be applied, and often times it's on another system. If custom tools are used those have to be passed to the other system to apply the ownership patch. Clearly not a big deal; but less optimal than if there was a standard way to do it. – Catskul Jun 21 '12 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.