Skip to content

Commit ff99fcf

Browse files
committed
add -nouser and -nogroup options
1 parent 2bdddf8 commit ff99fcf

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

tools/find_pl/find_pl

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use strict;
55
use File::Find;
66
use Cwd ();
7+
use POSIX qw(getpwuid getgrgid);
78

89
sub usage {
910
print <<"USAGE";
@@ -13,20 +14,20 @@ EXPRESSION
1314
The part of the command line after the list of starting points is the expression.
1415
This is a kind of query specification describing how we match files and what we do with the files that were matched. An expression is composed of a sequence of things:
1516
16-
Tests Tests return a true or false value, usually on the basis of some property of a file we are considering. The -empty test for example is true only
17-
when the current file is empty.
17+
Tests Tests return a true or false value, usually on the basis of some property of a file we are considering. The -empty test for example is true only
18+
when the current file is empty.
1819
19-
Actions
20-
Actions have side effects (such as printing something on the standard output) and return either true or false, usually based on whether or not they
21-
are successful. The -print action for example prints the name of the current file on the standard output.
20+
Actions
21+
Actions have side effects (such as printing something on the standard output) and return either true or false, usually based on whether or not they
22+
are successful. The -print action for example prints the name of the current file on the standard output.
2223
23-
Global options
24-
Global options affect the operation of tests and actions specified on any part of the command line. Global options always return true. The -depth
25-
option for example makes find traverse the file system in a depth-first order.
24+
Global options
25+
Global options affect the operation of tests and actions specified on any part of the command line. Global options always return true. The -depth
26+
option for example makes find traverse the file system in a depth-first order.
2627
27-
Operators
28-
Operators join together the other items within the expression. They include for example -o (meaning logical OR) and -a (meaning logical AND).
29-
Where an operator is missing, -a is assumed.
28+
Operators
29+
Operators join together the other items within the expression. They include for example -o (meaning logical OR) and -a (meaning logical AND).
30+
Where an operator is missing, -a is assumed.
3031
3132
GLOBAL OPTIONS
3233
-maxdepth LEVELS
@@ -60,6 +61,12 @@ TESTS
6061
-name PATTERN
6162
File name matches specified glob wildcard pattern (just as with using find).
6263
64+
-nogroup
65+
No group corresponds to file's numeric group ID.
66+
67+
-nouser
68+
No user corresponds to file's numeric user ID.
69+
6370
-path PATTERN
6471
File path matches specified glob wildcard pattern (just as with using find).
6572
@@ -224,6 +231,10 @@ while (@ARGV) {
224231
$wanted .= "\$File::Find::name =~ /" . fileglob_to_regex(shift) . "/s";
225232
} elsif ($arg_option eq "-ipath") {
226233
$wanted .= "\$File::Find::name =~ /" . fileglob_to_regex(shift) . "/si";
234+
} elsif ($arg_option eq "-nogroup") {
235+
$wanted .= "(!getgrgid(\$gid))";
236+
} elsif ($arg_option eq "-nouser") {
237+
$wanted .= "(!getpwuid(\$uid))";
227238
} elsif ($arg_option eq "-atime") {
228239
my $atime = shift;
229240
($atime =~ /^([\+\-]?)(\d+)$/) || die ("find.pl: invalid argument to -atime: $atime\n");

0 commit comments

Comments
 (0)