13

How do I find files not belonging to particular group?

find /home -group NOT test
20

find /home -not -group test or find /home ! -group test

The exclamation inverts the match. From man find:

 ! expr True  if  expr  is false.  This character will also usually need

 -not expr
          Same as ! expr, but not POSIX compliant.

If you want the group it does belong to in the output:

find /home ! -group test -printf "%p:%g\n"
./lots/573:root
...

Some more information on using find:
How do I master the UNIX find command?

|improve this answer|||||
  • +1 - didn't know you could do that. – Dave Holland Apr 15 '10 at 14:02
  • +1 -- good trick, didn't know this was an option either... :] – Kyle Smith Apr 15 '10 at 16:21
0

Do a grep excluding the things you don't want?

|improve this answer|||||
  • like how do I get the groups listed with find? I would appreciate an example – Michael Apr 15 '10 at 13:50
  • 1
    How about instead you use Kyle's answer, which is a better solution. – Dave Holland Apr 15 '10 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.