the command groups's output for a specific user
consists of :[IN RedHat]
the primary group for the user then any other groups he is member of
So the idea is to take the field/s after the primary group
then add it/them comma separated with the new group we want to add a user in
then the command would be something like that
### groups $uzr
output would be
$user : user group1 group2 [and so on]
Or
$user : user group1
then we've to do
### usermod -G <newgroup,group1,group2> <$user>
--But the problem taking this/those field/s
<the output from the groups command>
then add them comma separated to usermod command like that
groups $uzr | cut -f4,5,6 -d \ ;
usermod -G $1,$x,$z $uzr
where is $1 is the group name u added
$x,$z ...suppose to be the groups which the user
is already member of
How to add them (old_groups) comma separated with -G
_______________________________________________
--this script is very useful in a large network cause it would be silly to add
--all users manually