15

How do I find files not belonging to particular group?

find /home -group NOT test

2 Answers 2

23

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?

2
  • +1 - didn't know you could do that. Apr 15, 2010 at 14:02
  • +1 -- good trick, didn't know this was an option either... :]
    – Kyle Smith
    Apr 15, 2010 at 16:21
-1

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

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

You must log in to answer this question.

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