How to process the user id list in /etc/group?

To all,
I need to find a group in /etc/group and if found, I need to list out all the login ids for that group - one login id per line.

To find the list of user login ids for group X, I probably will use

cat /etc/group|grep ^X:|cut -d: -f4

This will return back a list of comma delimited login ids.

Here's my problem.

How do I print each login id on one line?

Or is there a better way of doing this?

Please help.
Thanks.

$ echo a,b,c | tr ',' '\n'
a
b
c

That should help.

Yup, that works.

Now that I have the report, my boss added a new requirement. He wants the user ID and the user's real name on the same line.

Any idea?

Thanks.

That's simple. grep(1) for the uid in /etc/passwd and take the 5th field using cut(1).

Yes, I know that's simple. I know how to get the name once I have a user id. My problem is I need to somehow scan thru the comma delimited user id list and retrieve one id at a time so that I can find the name in the passwd file.

My original command will give me the user login id list.

    cat /etc/group|grep ^X:|cut -d: -f4

How do I scan thru this login id list, find the name for each of the ids, and print each id & name per line?

For example, the list of ids is ID1,ID2,ID3.

I want the report to show

ID1 John Doe
ID2 Jane Doe
ID3 John Smith

I hope this is clear. If not, let me know.
Thank you very much for your help.