gpt4 book ai didi

bash - chmod:仅当文件是目录时执行

转载 作者:行者123 更新时间:2023-12-05 05:25:25 26 4
gpt4 key购买 nike

我知道 chmod -R u=rwX,g=rwX,o=r 将设置目录、子目录和文件,但要注意:

The capital X permission option tells chmod to grant execute access only if it makes sense -- if the item is a directory, or already has at least one execute access enabled (i.e. if it appears to be an executable file).

但是有没有办法强制 chmod(以类似的方式)只影响目录,而让所有文件保持原样?

Source

最佳答案

find my/path -type d -exec chmod u=rwX,g=rwX,o=r {} \;
+ + + + +------+------+ + +
| | | | | | +-> semicolon needed by -exec and escaped to avoid shell expansion
| | | | | +-----> current directory entry returned by find
| | | | +--------------> your chmod options
| | | +-------------------------> the shell command you want to execute on each directory entry
| | +-------------------------------> need to execute a command for each entry returned by find
| +-----------------------------------> look for directories only (not files/symlinks/etc)
+----------------------------------------------> the path to look for entries in

关于bash - chmod:仅当文件是目录时执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31014236/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com