in reply to To get the secondary groups for linux
Output:use strict; my @sec_gp; my $name = "xxxxx"; while (my ($gname,$gpasswd,$gid,$members)=getgrent) { my @list_members=split (/\s+/,$members); my @list=grep (/$name/,@list_members); if ($list[0] eq $name) { push (@sec_gp,"$gname"); } } print "\@sec_gp: "; print "$_\n" foreach @sec_gp;
@sec_gp: acad libsoftwrite helpdesk codes
--Jim Update: The above was hastily done. Better is the following (still room for improvement I'm sure):
for the original if statement.push(@sec_gp, "$gname") if $list[0] eq $name;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: To get the secondary groups for linux
by tbo (Scribe) on Jan 08, 2002 at 14:46 UTC |