How do I list all members of a group in Linux (and possibly other unices)?
You can do it in a single command line:
cut -d: -f1,4 /etc/passwd | grep $(getent group | cut -d: -f3) | cut -d: -f1
Above command lists all the users having groupname as their primary group
If you also want to list the users having groupname as their secondary group, use following command
getent group | cut -d: -f4 | tr ',' '\n'