find all files and folders which have specific owner/group with grep

In home/oracle I have many files and folders.

I need 2 different codes to:

  • find (show) all files and folders belongs to user "Jim" from group "app"
  • Change user owner of all files and folders from (Jim) to Harry.

Is it possible to do it with grep?


Solution 1:

Read man find xargs chown and do something like (Untested)

find /home/oracle \( -user Jim -a -group app \) -print0 | \
  xargs -0 --no-run-if-empty \
    echo sudo chown Harry

Remove the echo after testing.

You can't do it with grep. grep searches the content of files, you want to check and modify the files' metadata.