如果我需要使用组权限搜索文件,我使用以下命令
echo **/*(AIE)
其中 AIE 代表读/写/执行。
对于所有者和组权限,使用的限定符分别是 rwx 和 RWX。
使用 AIE 背后的想法是什么?
答案1
示例的命令参数
echo **/*(AIE)
zsh
使用;的全局语法例如,
它不适用于。bash
中的字符()
是全局限定符;多个限定符按逻辑组合AND
- 也就是说,它们都需要应用。
因此上面的命令显示了该组可读、可写和可执行的文件名。他们拥有由 设定的权限chmod g+rwx
。
按权限搜索文件的更便携方法是使用-perm
的 测试find
,例如:
find -perm -g=rwx
除了独立于 shell 工作之外,语法也更具可读性。
从man zshall
:
Glob Qualifiers
Patterns used for filename generation may end in a list of qualifiers
enclosed in parentheses. The qualifiers specify which filenames that other‐
wise match the given pattern will be inserted in the argument list.
If the option BARE_GLOB_QUAL is set, then a trailing set of parentheses con‐
taining no `|' or `(' characters (or `~' if it is special) is taken as a set
of glob qualifiers. A glob subexpression that would normally be taken as
glob qualifiers, for example `(^x)', can be forced to be treated as part of
the glob pattern by doubling the parentheses, in this case producing
`((^x))'.
If the option EXTENDED_GLOB is set, a different syntax for glob qualifiers
is available, namely `(#qx)' where x is any of the same glob qualifiers used
in the other format. The qualifiers must still appear at the end of the
pattern. However, with this syntax multiple glob qualifiers may be chained
together. They are treated as a logical AND of the individual sets of
flags. [...]
[ ... ]
A group-readable files (0040)
I group-writable files (0020)
E group-executable files (0010)
R world-readable files (0004)
W world-writable files (0002)
X world-executable files (0001)
请参阅man zshall | less '+/Glob Qualifiers'
或pinfo zsh