I have tried getent, group command, id -Gn $user and some sed combination but I don't think I am able to achieve hence reaching out to fellow programmers.
I want to be able to print this : groups abc123
Output
abc123 : devops build test design
Expected Output
groups:
- devops
- build
- test
- design
Using the id command The id command prints information about the specified user and its groups. If the username is omitted it shows information for the current user. To print only the names instead of the numbers use the -n option. Option -g will print only the primary group and -G all groups.
using bash
:
for i in `groups`; do echo $i; done
using tr
:
groups | tr \ \\n
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With