How to tell if a user is a group member in a script?
matthew at linuxfromscratch.org
Wed Oct 20 15:13:59 PDT 2004
Kevin P. Fleming wrote:
> I have a need to determine (in a bash script) whether the current user
> is a member of a given group, and I don't really want to parse
> /etc/group myself.
> Anyone have any quick suggestions?
I can cheat :) You said you didn't want to parse /etc/group. How about
parsing /etc/passwd instead then to get a list of users :) You can then
loop over that list and run 'groups' on them :)
More information about the lfs-chat