如何递归地修改所有文件夹,排除特定文件夹中的所有文件夹?

Kra*_*ime 2 linux bash permissions chmod find

我想要chmod特定文件夹中的所有文件夹和子文件夹,但我希望排除一个文件夹(及其包含的所有子文件夹)。

到目前为止,我对 StackOverflow 中的以下解决方案进行了破解:

这是我到目前为止的想法:

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

问题是有或没有-print我收到以下错误:

查找:缺少`-exec'的参数

以下行具有我需要-exec chmod 644{}\;从中读取的预期结果:

find . -type d \( -path ./node_modules \) -prune -o -print
Run Code Online (Sandbox Code Playgroud)

我在那条线上缺少什么来管道数据-exec

Ale*_*lex 5

删除-print、转义( and )并在后面添加空格{}

find . -type d \( -path ./node_modules \) -prune -o -exec chmod 644 {} \;
Run Code Online (Sandbox Code Playgroud)


Kra*_*ime 5

经过一番玩耍后,我发现以下对我有用:

chmod 所有文件递归排除文件:

find . -not -path "*/node_modules*" -type f -exec chmod 644 {} \;
Run Code Online (Sandbox Code Playgroud)

chmod 所有文件夹递归排除文件夹:

find . -not -path "*/node_modules*" -type d -exec chmod 755 {} \;
Run Code Online (Sandbox Code Playgroud)