linux - chmod 递归,但排除起始目录

标签 linux debian redhat file-permissions chmod

据我所知,我遇到了 chmod 的限制 - 希望在编写一些查找脚本之前在这里挑选更有经验的人。

我想 chmod -R 文件夹内的所有文件和目录,但不保留文件夹本身。我需要避免在此过程中更改起始目录的权限,因此不能选择简单的 chmod -R 后跟非递归 chmod 来重置起始目录的权限。

有什么想法吗?

最佳答案

只需对目录内的所有文件和子目录进行 chmod 操作,而不是对目录本身进行操作。这可以通过 glob 模式轻松完成:

chmod -R dir/*

如果您想考虑隐藏文件和目录,可以在 bash 中shopt -s dotglob

关于linux - chmod 递归,但排除起始目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62379413/

相关文章:

linux - Clearcase 与 hudson 集成以实现持续集成

linux - Linux 中的 Netbeans 和 Xdebug

linux - 更改了 www 的权限,但 Apache 仍然没有权限

Android SDK 平台工具无法在 Debian 7 上安装

c - FFmpeg vaapi_transcode 示例执行错误

linux - 在没有 root 权限的情况下检查 github 企业中的备份状态?

linux - 使用终端命令在 chrome 中设置主页

audio - 将在RedHat中运行的Orion Context Broker连接到Raspberry Pi

linux - 在 weblogic 11g 中设置首选监听地址

redhat - 卸载 REPO [yum]