http://www.perlmonks.org?node_id=686055
Description: You just added a user to your UNIX system. You want him to belong to all groups where you belong. E.g.: let's say your user name is bronto and the new user is robin. Here we go.
perl -F: -i.save -ape 'if ($F[3] =~ m{bronto} and not m{robin}) { chom
+p ; $_ .= qq{,robin\n} }' /etc/group