Copy file permissions, but not files [closed]
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,
You could use this script (it changes the permissions recursively but individually for each file/directory)
#!/bin/shchmod --reference $1 $2if [ -d $1 ]then if [ "x`ls $1`" != "x" ] then for f in `ls $1` do $0 $1/$f $2/$f done fifi
Run the script with arguments version2 version1
You could try:
chmod owner-group-other ./dir or ./file
Unless permissions are fine grained and different from one file to another, you could do a recursive chmod on the directory and unify the permissions.
See man chmod for references on the options that might be useful