Bash 查找具有特定组权限的文件,无论用户和其他人的权限如何

Bash 查找具有特定组权限的文件,无论用户和其他人的权限如何

仅使用八进制表示法,我需要找到仅对组具有读取权限的文件,无论所有者和其他权限是谁。

哪个是正确的命令?我找不到它。

谢谢。

答案1

查找(1) 手册说明了一切:

   -perm -mode
          All of the permission bits mode are set for the file.
          Symbolic modes are accepted in this form, and this is usually
          the way in which would want to use them.  You must specify
          `u', `g' or `o' if you use a symbolic mode.   See the EXAMPLES
          section for some illustrative examples.

   -perm /mode
          Any of the permission bits mode are set for the file.
          Symbolic modes are accepted in this form.  You must specify
          `u', `g' or `o' if you use a symbolic mode.  See the EXAMPLES
          section for some illustrative examples.  If no permission bits
          in mode are set, this test matches any file (the idea here is
          to be consistent with the behaviour of -perm -000).

   -perm +mode
          This is no longer supported (and has been deprecated since
          2005).  Use -perm /mode instead.

   -readable
          Matches files which are readable.  This takes into account
          access control lists and other permissions artefacts which the
          -perm test ignores.  This test makes use of the access(2)
          system call, and so can be fooled by NFS servers which do UID
          mapping (or root-squashing), since many systems implement
          access(2) in the client's kernel and so cannot make use of the
          UID mapping information held on the server.

我不会在这里给出简单的答案,因为坦率地说这是一个很容易弄清楚的事情。

相关内容