find / -group <groupname> -exec chown :<groupname> {} \+
should do the trick. Just replace <groupname>
with the appropriate name.
find
allows you to call arbitrary commands on the files it returns, using the -exec
primary. In this case, as we know we want to change the group ownership of each matching file, we can simply pass the chown
command (and any arguments - in this case, the group name to whose ownership we wish to transfer matching file names, preceded by :
, which tells chown
to treat it as a group name and not as a user name) as the argument to -exec
. The file name returned by find
is inserted into the command in place of the {}
, and +;
tells find
that it has reached the end of the external command, and should parse any additional parameters as its own. Using \+
rather than \;
tells find to process multiple files in each command (so it's more efficient).