#!/usr/bin/perl -w # Find unused Groups in /etc/group use strict; my $GROUPfile="/etc/group"; my $PASSWD="/etc/passwd"; open my $gh, "<", $GROUPfile or die "$GROUPfile Open failed: $!\n"; open my $ph , "<", $PASSWD or die "$PASSWD Open failed: $!\n"; my %gids = map { (split /:/)[3] => 1 } <$ph>; while (<$gh>) { my @fields = split /:/; next if length $fields[3] > 1; next if $gids{$fields[2]}; print "$fields[0] has no users and no GID references\n" }