user5112765
user5112765

Reputation:

Unix Shell -- Issue a command that changes permissions for all files and directories excluding one

I am trying to recursively change permissions for all directories and files within my current working directory but while excluding one of the directories.

I have tried a bunch of variations of the following command and can't get it quite right

find . -type d ! -name directoryName -exec chmod -R 700 {} +

Upvotes: 0

Views: 38

Answers (2)

user5112765
user5112765

Reputation:

This did it. Thank you guys for the suggestions.

find . ! -name website ! -path "./website/*" -exec chmod 700 {} +

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798746

The -R argument to chmod tells it to work recursively. Since you're enumerating all the objects individually you should not use this option.

Upvotes: 1

Related Questions