Skip to content

Instantly share code, notes, and snippets.

@rc5hack
Created July 12, 2013 06:09
Show Gist options
  • Save rc5hack/5982270 to your computer and use it in GitHub Desktop.
Save rc5hack/5982270 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl --
use File::Find;
my $directory1 = $ARGV[0];
my $directory2 = $ARGV[1];
find(\&hashfiles, $directory1);
sub hashfiles {
my $file1 = $File::Find::name;
(my $file2 = $file1) =~ s/^$directory1/$directory2/;
my $mode1 = (stat($file1))[2] ;
my $mode2 = (stat($file2))[2] ;
my $uid1 = (stat($file1))[4] ;
my $uid2 = (stat($file2))[4] ;
print "Permissions for $file1 ($mode1) and $file2 ($mode2) are not the same\n" if ( $mode1 != $mode2 );
print "Ownership for $file1 and $file2 are not the same\n" if ( $uid1 != $uid2 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment