How do I find files not belonging to particular group?

find /home -group NOT test
link|improve this question

53% accept rate
feedback

2 Answers

up vote 4 down vote accepted

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:
http://serverfault.com/questions/29489/how-do-i-master-the-unix-find-command

link|improve this answer
+1 - didn't know you could do that. – Dave Holland Apr 15 '10 at 14:02
exactly what I want! Thanks – Michael Apr 15 '10 at 14:17
+1 -- good trick, didn't know this was an option either... :] – Kyle Smith Apr 15 '10 at 16:21
feedback

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

link|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
How about instead you use Kyle's answer, which is a better solution. – Dave Holland Apr 15 '10 at 14:02
feedback

Your Answer

 
or
required, but never shown

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