0

I would like to change the permission recursively all files and directories but exclude some directories.

find . -name user -prune -o -type d -exec chmod 755 {} \;

But using this, its only change the directories but not recursively. The content of directories not change.

while,

find . -name user -prune -o -type d -exec chmod -R 755 {} \;

This will change all directories and its contents and include the 'user'directory which i want to exclude.

So, how to change the permission recursively all files and directories but exclude user directory?

Thanks in advance.

1 Answer 1

1

This can be accomplished with the -path parameter.

find . -path dir -prune -o -name user -type d -exec chmod -R 755 {} \;

If you wish to ignore multiple directories you can do.

find . \( -path dir1 -o -path dir2 -o -path dir3 \) -prune -o -name user -type d -exec chmod -R 755 {} \;
2
  • i got this error: find: bad option -path find: [-H | -L] path-list predicate-list
    – wina
    Sep 1, 2016 at 2:47
  • Sorry I don't have access to my terminal so you'll have to wait for another answer.
    – likewhoa
    Sep 1, 2016 at 3:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .