Skip to content

Instantly share code, notes, and snippets.

@gingerhot
Last active October 10, 2015 16:47
Show Gist options
  • Save gingerhot/3720982 to your computer and use it in GitHub Desktop.
Save gingerhot/3720982 to your computer and use it in GitHub Desktop.
A simple Perl script using a build-in module File::Find to validate some files based on combination of file types and ownership
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
use v5.10;
my @dir = qw(/Path/To_Your_Dir/);
my $buser = 'Legal_User_Name';
my @danger;
sub compare {
my $filename = $File::Find::name;
my $uid = (stat $filename)[4];
my $user = (getpwuid $uid)[0];
push @danger, $filename if ($user ne $buser) and $filename =~ /\.php$/;
}
find(\&compare, @dir);
say join "\t", @danger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment