If i need to search files using group permission I use the following command

echo **/*(AIE)

where AIE stand for read/write/execute.

For owner and group permissions the qualifier used are rwx and RWX respectively.
What is the idea behind using AIE?


1 Answer 1


The command argument of the example

echo **/*(AIE)

uses the glob sntax of zsh;
It does not work for bash, for example.

The characters in the () are glob qualifiers; Multiple qualifiers are combined by logical AND - that is, they all ned to apply.

So the command above shows filenames that are readable, writable and executable for the group. They have the permissions that are set by chmod g+rwx.

A more portable way to search files by permissions is using the -perm test of find, for example:

find -perm -g=rwx 

Besides working independent of the shell, the syntax also tends to be more readable.

From 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

    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)

See man zshall | less '+/Glob Qualifiers' or pinfo zsh

  • Thanks Volker. I should have also mentioned about zshell. Commented Sep 20, 2014 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .