Assuming that usernames are in users.txt file
Code:
user1
user2
user3
user4
Here is the script, that keep old member ship and add user to new groups defined by $nGROUPS, as usual backup /etc/group and other files before running script:
Code:
#!/bin/bash
INPUT=users.txt
USERS=$(cat $INPUT)
nGROUPS="ftp, sales"
mGROUPS=""
for u in $USERS
do
pGgroups="$(id -Gn ${u} | sed -e 's/ /,/g')"
mGROUPS="${pGgroups},${nGROUPS}"
# old version
usermod -G $mGROUPS $u
# new version group add needs no hack
# usermod -a $nGROUPS $u
done
Above script is just demonstration, feel free to modify as per your UNIX / Linux setup.
__________________
Vivek Gite
Linux Evangelist

Be proud
RHEL user, and let the world know about your enterprise choices!
Join RedHat user group.

Always use
CODE tags for posting system output and commands!

Do you run a Linux? Let's face it,
you need help