Last active
October 10, 2015 16:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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