FIND(1) | NetBSD General Commands Manual | FIND(1) |
find | [-H | -L | -P] [-dEhsXx] file [file ...] [expression] |
find | [-H | -L | -P] [-dEhsXx] -f file [file ...] [expression] |
The options are as follows:
If terminated by a semicolon (“;”), the utility is invoked once per path. If the string “{}” appears anywhere in the utility name or the arguments, it is replaced by the pathname of the current file.
If terminated by a plus sign (“+”), the pathnames for which the primary is evaluated are aggregated into sets, and utility will be invoked once per set, similar to xargs(1). If any invocation exits with non-zero exit status, then find will eventually do so as well, but this does not cause find to exit early. The string “{}” must appear, and must appear last. Each set is limited to no more than 5,000 pathnames, and is also limited such that the invocation of utility does not exceed ARG_MAX.
sysctl vfs.generic.fstypes
In addition, there are two pseudo-types, “local” and “rdonly”. The former matches any file system physically mounted on the system where the find is being executed, and the latter matches any file system which is mounted read-only.
All primaries which take a numeric argument allow the number to be preceded by a plus sign (“+”) or a minus sign (“-”). A preceding plus sign means “more than n”, a preceding minus sign means “less than n”, and neither means “exactly n”.
All operands and primaries must be separate arguments to find. Primaries which themselves take arguments expect each argument to be a separate argument to find.
The options and the -amin, -anewer, -cmin, -cnewer, -delete, -empty, -execdir, -follow, -fstype, -iname, -inum, -iregex, -links, -ls, -maxdepth, -mindepth, -mmin, -path, -print0, -printx, -regex, and -rm primaries are extensions to IEEE Std 1003.2 (“POSIX.2”).
Historically, the -d, -h, and -x options were implemented using the primaries “-depth”, “-follow”, and “-xdev”. These primaries always evaluated to true. As they were really global variables that took effect before the traversal began, some legal expressions could have unexpected results. An example is the expression “-print -o -depth”. As -print always evaluates to true, the standard order of evaluation implies that -depth would never be evaluated. This is not the case.
The operator “-or” was implemented as “-o”, and the operator “-and” was implemented as “-a”.
Historic implementations of the -exec and -ok primaries did not replace the string “{}” in the utility name or the utility arguments if it had preceding or following non-whitespace characters. This version replaces it no matter where in the utility name or arguments it appears.
Support for “-exec ... +” is consistent with IEEE PASC Interpretation 1003.2 #210, though the feature originated in SVR4.
The -delete primary does not interact well with other options that cause the file system tree traversal options to be changed.
As there is no delimiter separating options and file names or file names and the expression, it is difficult to specify files named “-xdev” or “!”. These problems are handled by the -f option and the getopt(3) “--” construct.
November 6, 2009 | NetBSD 5.99 |