#!/usr/bin/perl -w # Find unused Groups in /etc/group use strict; my $GROUPfile="/etc/group"; my $gfpid = open(GFILE, "<", $GROUPfile) or die "$GROUPfile Open failed: $!\n"; my $PASSWD="/etc/passwd"; my $pfpid = open(PFILE, "<", $PASSWD) or die "$PASSWD Open failed: $!\n"; my %gids; while (my $line = ) { my @user = split /:/, $line; $gids{$user[3]}++; } while (my $line = ) { my @GRP = split(/:/, $line); if (length $GRP[3] > 1) { # $GRP[0]:$GRP[2] is not zero length next; } if ($gids{$GRP[2]}) { # GID found in passwd next; } print "$GRP[0] has no users and no GID references\n" }