0

I need to do something like this

grep -R 'MyString' dir/

But instead of searching within a directory, I'd like to search all files owned by a specific group. Is this possible?

ekad
  • 14,436
  • 26
  • 44
  • 46
ZakTaccardi
  • 12,212
  • 15
  • 59
  • 107

1 Answers1

4

Use the -group option of find as shown below:

find mydir -group mygroup -type f -print0 | xargs -0 grep MyString
dogbane
  • 266,786
  • 75
  • 396
  • 414
  • 1
    It's safer to use null-delimited output (by using `print0` and `xargs -0`) so that filenames containing newlines are handled correctly. – dogbane Jun 03 '14 at 15:47