Skip to content

Instantly share code, notes, and snippets.

@iancclark
Created September 14, 2018 13:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iancclark/a1283c7e090b753203fa0821f8461130 to your computer and use it in GitHub Desktop.
Save iancclark/a1283c7e090b753203fa0821f8461130 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl -w
my $change=0;
my %uids=(
1234=>4567,
);
my %gids=(
5432=>2345,
);
my (undef,undef,undef,undef,$uid,$gid,undef,undef) = stat($ARGV[0]);
if(defined($uids{$uid})) {
$uid=$uids{$uid};
$change=1;
}
if(defined($gids{$gid})) {
$gid=$gids{$gid};
$change=1;
}
if($change==1) {
chown $uid, $gid, $ARGV[0];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment