Re: Scan disk for files with certain owner



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'd use some combination of File::Find with getgrgid and getpwuid with the wanted callback.

#!/usr/bin/perl -w
use strict;

use File::Find;

my @directories = ('/dir1','/dir2');

find(\&wanted,@directories);

sub wanted {
my ($dev, $ino, $mode, $nlink, $uid, $gid) = lstat($_);
if (!(defined(getpwuid($uid)) && defined(getgrgid($gid)))) {
print $File::Find::name . "\n";
}
}

On Feb 28, 2007, at 12:12 AM, Andreas Moroder wrote:

Hello,

I need a perl script that runs under linux that should recursively search the directory tree and print out all the files that have a uid or gid that does not resolv to a username or userid.

Can anyone give me a hint ?

Thanks
Andreas


--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (Darwin)

iD8DBQFF5T2VuT/QpFTX5YIRAlJ7AKDQThpftG/RhzKpGjT8bEWSv4S1FgCcCDkJ
l74ux3NssrPN5MuwO2h8YDE=
=0jTF
-----END PGP SIGNATURE-----
.