Re: get list of users in group
On Mon, 21 Jul 2008 08:46:14 +0200, Valerio Pachera <firstname.lastname@example.org>
Hi all, may you write me how to get (for example) the list of all the
I mean by bash, not by LWAT.
I need that for a script.
getent group teachers |cut -d: -f4 |tr ',' '\n'
[getent group teachers] will also list name of group, gid, users etc, but
you probably just want the usernames. So piping the output to [cut -d:
-f4] will show only the 4th field, the 4th field being the user names. The
users will then be listed on one line, separated by commas. Then when you
add [tr ',' '\n'] it translates all commas to new lines, so the result
will be a list with all users in teachers group, each username on a new