8

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.

Catskul
  • 1,839
  • 4
  • 20
  • 23

1 Answers1

4

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.

Zoredache
  • 128,755
  • 40
  • 271
  • 413
  • 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 00: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