In -type d \( -perm -0002 -a ! -perm -1000 \)
, first, the slashes escape the parenthesis for the shell, so they can be passed as an argument, instead of being interpreted as special operators by the shell. (You'd need the same for e.g. >
, for obvious reasons.) They could be written as '('
or "("
, too, but eventually find
only sees (
and )
.
The parenthesis group the conditions, and -a
is an and conjunction. That's also the implicit default for back-to-back conditions, like used here with -type d
and the expression in parenthesis, there's no explicit -a
connecting them. The expression is exactly equivalent to -type d -perm -0002 ! -perm -1000
. Parenthesis are really only needed in with the or conjunction -o
.
-type d
is obvious, and -perm -NNNN
means to look for a file with all of the permission bits NNNN
set. Or, in this case, directories with the write for others permission (0002
) set, and the sticky bit (1000
) unset (because of the negation). I think the combination here could also be written as -perm -o+w ! -perm -o+t
. Note the dash in front of the permission string, without it, the meaning would be different.
See e.g. the Linux man page for find, look for "( expr )" and "-perm mode".
Write access to a directory allows creating, removing and renaming files inside it, and the sticky bit prevents removing and renaming files owned by other users. The whole expression looks for directories where anyone can remove or rename any files.