这应该这样做:
find /Users -maxdepth 2 \! -perm 0700 \! -name Public \! -name Sites -type d -exec chmod 700 {} +
没有管道,只有一个命令:)
注意:我已将您的更改-depth 2
为-maxdepth 2
并将其移到前面...只是因为 GNU不能这样工作,我相信这就是用 GNU 编写的方式。现在,我不知道你在你的系统上安装了什么,所以 YYMV,就像他们说的......find
-depth
find
find
我也会使用chmod
'-v
选项,如果有的话,只是为了知道发生了什么……比如:
`chmod -v 700 {}`
尝试我给你的命令,如下所示:
find /Users -maxdepth 2 \! -perm 0700 \! -name Public \! -name Sites -type d -exec echo chmod 700 {} +
与echo
那里,所以它是无害的。它只会在您的屏幕上打印echo
删除时将执行的命令。echo
仅当您对它的行为方式感到满意时才删除它。
编辑。似乎 OS X 和 GNU 版本在/find
的使用上有所不同。所以这里有一个类似的 OS X 命令(见下面Dan的评论):-depth
-maxdepth
find /Users -depth 2 \! -perm 0700 \! -name Public \! -name Sites -type d -exec echo chmod 700 {} +
干杯!