Skip to content
Advertisement

recursively find directories without setgid set

In linux, how do you recursively pull up a list of all directories that do NOT have the setgid bit set?

I know you can do

find . -type d /perm g+s

to find all the directories that have it set, but it’s not obvious to me how to negate this. Or if another tool is more appropriate for this use case.

I’ve got a rather large directory tree and I’m trying to limit the operations I do on them.

Advertisement

Answer

You can simply add ! before an expression in find in order to negate it.

find . -type d ! -perm -g+s
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement