Sometimes, thankfully not very often, I need to change the group or the user of many directories or files in a global way. This could happen owing to unfortunate circumstances, e.g when you switch a Serversystem to another and something went wrong or something happens you did not plan before.
With this command I find all directories inside of /var/www with the group-id 501.
then it will execute the command chgrp for changing the group-id to 33:
find /var/www -gid 501 -type d -exec chgrp 33 ‘{}’ ‘;
(You can also write ‘…chgrp www-data’)
I have to say, this command had saved my life, for more than one time.