Bob Beers wrote: > Part 1: > > > You have a valid point, but the OP's question was: > > "I am looking for a (simple) shell command to run from a bash script > that will allow me to list user accounts that belong to a particular > group." > > In all likelihood the system follows the default approach of setting the primary group to be the user's personal ground. If that is the case then you're correct in providing a simple solution as requested. I just wanted to make Tim aware that if his user's have primary groups other than their personal groups - e.g. "admin" or "marketing" - then there isn't a simple answer (not that the answer is all that hard). Here's a script I knocked up to do it - although there can be duplication and output formatting isn't perfect:- #!/bin/bash #set -x # $1 is the group to test if [ "$1" = "" ]; then echo "Which group?" exit 1 fi groupid=$(getent group $1 | cut -d: -f3) grouplst=$(getent group $1 | cut -d: -f4) for User in $(cat /etc/passwd | cut -f1 -d:) do if [ $(id -g $User) = $groupid ]; then grouplst="$(echo $grouplst),$User" fi done echo "Members of group $1 are: $grouplst" exit 0 Regards, Ian
<<attachment: smime.p7s>>
_______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos