How to chmod all folders recursively excluding all folders withing a specific folder?

1

1

I would like to chmod all folders and subfolders within a specific folder, except I wish to exclude one folder (and all subfolders it contains).

What I have so far, is a hack of the following solutions from StackOverflow :

Here is what I came up with so far :

find . -type d ( -path ./node_modules ) -prune -o -print -exec chmod 644 {}\;

The problem is with or without -print I receive the following error :

find: missing argument to `-exec'

The following line has the expected results I need -exec chmod 644{}\; to read from :

find . -type d ( -path ./node_modules ) -prune -o -print

What am I missing on that line to pipe the data to -exec ?

Kraang Prime

Posted 2017-01-08T04:10:14.920

Reputation: 133

Answers

2

Remove -print, escape ( and ) and add space after {}

find . -type d \( -path ./node_modules \) -prune -o -exec chmod 644 {} \;

Alex

Posted 2017-01-08T04:10:14.920

Reputation: 5 606

Your solution worked. Thank you. I was in the middle of writing my solution when you posted this. Accepting as solution and upvoted. – Kraang Prime – 2017-01-08T07:09:42.490

2

After some playing around, I found that the following worked for me :

chmod all files recursively excluding folder

find . -not -path "*/node_modules*" -type f -exec chmod 644 {} \;

chmod all folders recursively excluding folder

find . -not -path "*/node_modules*" -type d -exec chmod 755 {} \;

Kraang Prime

Posted 2017-01-08T04:10:14.920

Reputation: 133