Listing RealNames of all the users of an Open Directory group in MAC OS X I was looking an older post (https://superuser.com/questions/279891/list-all-members-of-a-group-mac-os-x/395738#395738) and I tried the code that the user Arne Stenström posted.

members () { dscl . -list /Users | while read user; do printf "$user "; dsmemberutil checkmembership -U "$user" -G "$*"; done | grep "is a member" | cut -d " " -f 1; };


It works perfectly but the output is a list of the users uid. I'm trying to get the RealNames too in order to have a list with the uid and the RealName at the output.

I tried infinite things and options but I'm not able to get it. I know that I can list the RealName of an user with this code:

dscl . -list /Users/username RealName


I can't find the way to join both ideas to reach the wanted result.

Could you please help me?

Thank you very much.
There's probably something wrong with this or an easier way to do the same thing, but could you just run dscl . -read /Search/Users/username RealName for all usernames?

g=admin; dscl . -list /Users | while read l; do printf %s "$l "; dsmemberutil checkmembership -U $l -G $g; done | grep 'is a member' | cut -d' ' -f1 | while read l; do echo "$l $(dscl . -read /Users/$l RealName | tail -n1 | cut -c2-)"; done