Tho*_*ard 8 command-line bash zsh shell-script
任何人都可以向我指出编写可以递归遍历整个目录结构的 shell 脚本的代码或教程(从当前工作目录开始,或者给出从哪里开始的必需参数)并且可以:
chmod 755
它,或...chmod 644
它。我正在寻找与 Ubuntu、Debian、基于 RHEL 等的兼容性,所以我没有用任何特定的语言来标记它。我希望在 Bash 中使用它,但是如果您有 ZSH 脚本,那也可以。
gui*_*ido 10
我习惯了这个单行命令(会从当前工作目录开始递归)
find . -type d -exec chmod 0755 '{}' + -or -type f -exec chmod 0644 '{}' +
Run Code Online (Sandbox Code Playgroud)
解释:
find . # starting in curdir find
-type d # any directory
-exec chmod 0755 '{}' # and chmod it to 755
+ # (variant of -exec look find man page)
-or # or
-type f # any file
-exec chmod 0644 '{}' # and chmod it to 644
+ # (as above)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1799 次 |
最近记录: |