ID - output group-memberships one per line

Hello,

I am currently a little bit lost with my new shell-script.
I am trying to output the results of the "id"-command as a "one per line" statement. For example:
I have the user "test" with the group-memberships "group1, group2, group3". When I enter "id test" it will show me the output "uid=222(test) gid=223(group1) groups=223(group1), 224(group2), 225(group3)". What I want to achieve is to output the results as
uid=222(test)
gid=223(group1)
groups=223(group1)
224(group2)
225(group3)

I want to achieve this because I want to insert the group-names into an array and continue to work with this array. I am stuck at this point, I am so far that I can output one group and only the name of that group with the help of awk - but I don't know how to go further from this point.
Can anyone pinpoint me into the right direction?

Your help is greatly appreciated, thanks in advance
Thomas

Try piping it into tr " ," "\n" .

1 Like

Wow - that was fast, and it works too :slight_smile:
Thank you very much!