find (target)
Find files (POSIX, toybox)
Syntax:
find [-HL] [dir...] [options]
Runs on:
QNX OS
Options:
- -H
- Follow command line symbolic links.
- -L
- Follow all symbolic links.
- dir
- The pathname of a directory in which find looks for files.
Description:
The find utility recursively descends the directory hierarchy for each file specified by path and seeks files that match operand_expression.
The operand expression follows one or more pathnames. The find utility treats as a pathname all the arguments up to the first one starting with any of these characters:
- ! (
Everything after that is part of the operand expression.
The primaries may be combined with the following operators. The operators are listed in order of decreasing precedence:
Operator | Action |
---|---|
(expression) | True if expression is true. |
! expression | (NOT) Negation of a primary or expression enclosed in parentheses. |
expression [-a] expression | (AND) True if both expressions are true. |
expression [-o] expression | (OR) True if either expression is true. |
Primary expressions
Whenever a primary expression uses a number (n), you can optionally
precede it by a plus (+
) or minus (-
) sign, which changes
the meaning as follows:
Expression | Means |
---|---|
+n | More than n |
-n | Less than n |
n | Exactly n |
- -atimen[u]
- File was accessed n units ago. The possible time units are shown
in the table below:
Time unit Meaning d Days h Hours m Minutes s Seconds - -contextpattern
- Security context of the file matches pattern.
- -ctime n[u]
- File was created n units ago.
- -depth
- Ignore contents of directory.
- -empty
- True if the file is a regular file of size zero, or a directory that contains no files.
- -executable
- Access (X_OK) permissions and access control list (ACL).
- -false
- Always false.
- -group group
- True if the file belongs to the group group.
- iname
- Ignore case -name.
- inum n
- True if the file has inode number n.
- -ipath
- Ignore case -path.
- -links n
- File has n hard links.
- -maxdepth n
- When this flag is set, find descends at most n directory levels down.
- -mindepth n
- When this flag is set, find doesn't apply any expressions unless they're at least n directory levels down.
- -mtime n[u]
- True if the file was modified n units ago.
- -name pattern
- True if the basename of the filename being examined matches a wildcard pattern.
- -newer file
- True if the current file has a newer modification time than file.
- -newerXY file
- True if the current file has a more recent acm time (X=acm time) than than the acm time of file (Y=acm time). In addition, if Y=t, then file is interpreted as the literal time.
- -nogroup
- True if the file belongs to a group ID that isn't known.
- -nouser
- True if the file belongs to a user ID that isn't known.
- -path pattern
- True if the pathname being examined matches a wildcard pattern.
- -perm [- | /] mode
- Any of the permission bits mode are set for the file.
- - = min
- / = any
- -prune
- Causes find to ignore directory contents.
- -quit
- Causes find to exit immediately.
- -samefile file
- True if the file is a hard link to file.
- -size n [c]
- True if the file size in bytes, divided by 512 and rounded up to the next integer, is n. If n is followed by c the size is in bytes.
- -true
- Always true
- -type [c]
- True if the file type is c where c is one
of:
Filetype Function b Block special file c Character special file d Directory f Regular file l Symbolic link p FIFO s Socket - -user uname
- True if file belongs to the user uname.
- -xdev
- Always true—stops find from descending past directories that have a different device ID.
Actions:
- -delete
- Remove matching files and directories.
- -exec
- Run command with path. The string
{}
is substituted by the current file name being processed. End the command with a semicolon (;
) to run each file, or plus (+
) sign to collect and run multiple files. - -execdir
- Run command in files directory.
- -ok
- Similar to -exec but find asks the user before executing.
- okdir
- Similar to -execdir but find asks the user before executing.
- Prints the current filename to standard output, followed by a new line.
- -printf format
- Print data pertaining to the file currently being evaluated to the standard output, according to the format string.
- -print0
- Print the current filename to standard output, followed by a null character.
Formatted Printing
The -printf
primary requires a format string as its arguments. The format string consists of regular
ASCII characters and a set of special codes starting with percent (%
)
format codes and backslash (\
) escape codes.
%b
- 512-byte blocks used.
%f
- Basename.
%G
- Numeric group ID.
%g
- Textual group ID.
%i
- Decimal inode.
%l
- Target of symlink.
%M
- Format type or mode of ls.
%m
- Octal mode.
%P
- Path to file minus dir.
%p
- Path to file.
%s
- Size in bytes.
%T@
- Mod time as unixtime.
%U
- Numeric user ID.
%u
- Username.
%Z
- Security context.
This utility is provided as part of the toybox package. For information on how to enable it, see toybox.
Contributing author:
Rob Landley and the toybox project (see https://landley.net/toybox/).