Folks, I got a working solution
Thanks to 'balajesuri' from 'The UNIX and Linux Forums' for this solution.
#!/usr/bin/perl
use strict;
use warnings;
my ($gid, $grp, $host, $group, $userid);
my %table;
open FILE, "< /path/to/usrgrps.txt";
foreach (<FILE>) {
chomp;
($host, $grp, $gid, $userid) = split /:/;
$group = "$grp:$gid";
if (length ($userid) != 0) {
(defined $table{$group} && $table{$group} =~ /$_/) ? next : ($
+table{$group}.="$_,") foreach (split /,/, $userid);
}
else {
$table{$group} = "";
}
}
close FILE;
foreach (sort keys %table) {
$table{$_} =~ s/,$//;
print "$_:$table{$_}\n";
}
Thank again to all for taking the time to look at this!!
All the best, g |