1
I have a question. So I have 2 folders, both of which have the same files in them, but some with different content, but the same names. What I want to do is clone all of the file permissions from one folder, into the permissions for another folder. Is this possible?
Could I use -R to do it to all files in the dir? – user1307079 – 2013-07-29T23:03:43.190
I am on my phone, can't try right now, but you should probably be able to. Otherwise, you could make a script that would recurse into subdirectories and do this for all the files. – Dominik Hadl – 2013-07-29T23:06:53.530
1It didnt seem to do it to recursively... I ran
chmod -R --reference=/home/tcagame_svc4/karl/4/garrysmod/ /home/tcagame_svc7/stefen/7/garrysmod/
– user1307079 – 2013-07-29T23:09:32.917Good idea by Tiago CA, maybe you should provide an asterisk after the slash, without specifying -R. – Dominik Hadl – 2013-07-29T23:40:57.487
Tiago CA's answer doesn't work for me, but this does:
for i in foo/*; do j=$(basename $i); chmod bar/$j --reference foo/$j; done
(you want to copy the permissions fromfoo
tobar
and they are flat directories). – Paulo Almeida – 2013-07-30T00:12:55.787@PauloAlmeida What do you mean by "flat" the directories have more than 1 directory inside of them. – user1307079 – 2013-07-30T00:26:56.227
By 'flat' I meant with no subdirectories. If there are subdirectories the script will be more complex. – Paulo Almeida – 2013-07-30T00:32:51.887
Hmmm... Is there a simple way to do it? @PauloAlmeida – user1307079 – 2013-07-30T00:41:57.687
If you want to copy the permissions in
bar
tofoo
, go intobar
and type this:find . -exec chmod --reference={} ../foo/{} \;
(this assumesfoo
andbar
are at the same level; if not, adjust the path in theexec
command). – Paulo Almeida – 2013-07-30T01:07:44.963