Re: Scan disk for files with certain owner
- From: neal.clark@xxxxxxxxx (Neal Clark)
- Date: Wed, 28 Feb 2007 00:30:13 -0800
-----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-----
.
- Follow-Ups:
- Re: Scan disk for files with certain owner
- From: Andreas Moroder
- Re: Scan disk for files with certain owner
- From: Neal Clark
- Re: Scan disk for files with certain owner
- References:
- Scan disk for files with certain owner
- From: Andreas Moroder
- Scan disk for files with certain owner
- Prev by Date: Scan disk for files with certain owner
- Next by Date: Re: Scan disk for files with certain owner
- Previous by thread: Scan disk for files with certain owner
- Next by thread: Re: Scan disk for files with certain owner
- Index(es):