You should have a look at the --reference
option for chmod
:
chmod --reference version2/somefile version1/somefile
Apply find
and xargs
in a fitting manner and you should be fine, i.e. something like
~/version2$ find . -type f | xargs -I {} chmod --reference {} ../version1/{}
This even works recursively, and is robust against missing files in the target directory (bar the No such file … errors, which can be ignored). Of course it won’t do anything to files that only exist in the target directory.
Cheers,