• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

find

find

find Finds files.
find [-H | -L | -P] [-Xdx] [-f <file>] <file> ....
									<expression>

find recursively descends the directory tree of each file listing, evaluating an <expression> composed of primaries and operands.
Options  
-H Causes the file information and file type returned for each symbolic link on the command line to be those of the file referenced, rather than those of the link itself. If the file does not exist, the information is for the link itself. File information of symbolic links not on the command line is that of the link itself.
-L Causes the file information and file type returned for each symbolic link to be those of the referenced file, rather than those of the link itself. If the referenced file does not exist, the information is for the link itself.
-P Causes the file information and file type returned for each symbolic link to be those of the link itself.
-X Permits find to be safely used with xargs. If a filename contains any delimiting characters used by xargs, an error message is displayed and the file is skipped. The delimiting characters include single quote, double quote, backslash, space, tab, and newline.
-d Causes a depth-first traversal of the hierarchy. In other words, directory contents are visited before the directory itself. Default is for a directory to be visited before its contents.
-x Excludes find from traversing directories that have a device number different from that of the file from which the descent began.
-h Causes the file information and file type returned for each symbolic link to be those of the referenced file, rather than those of the link itself. If the referenced file does not exist, the information returned is for the link itself.
-f Specifies a file hierarchy for find to traverse. File hierarchies may also be specified as operands immediately following the options listing.
Primaries (expressions)  
All primaries that can take a numeric argument allow the number to be preceded by +, -, or nothing. n takes on the following meanings:
  +n More than n
  -n Less than n
  n Exactly n
-atime n True if the file was last accessed n days ago. Note that find itself will change the access time.
-ctime n True if the file's status was changed n days ago.
-mtime n True if the file was last modified n days ago.
-newer <file> True if the current file has a more recent modification time than <file>.
-exec <command>; True if <command> returns a zero value exit status. Optional arguments may be passed to <command>. The expression must be terminated by a semicolon. If {} appears anywhere in the command name or arguments, it is replaced by the current pathname.
-follow Follows symbolic links.
-fstype True if the file is contained in a file system specified by -fstype. Issue the command:

sysctl vfs

to determine the available types of file systems on the system. There are also two pseudo-types: local and rdonly. local matches any file system physically mounted on the system where the find is being executed; rdonly matches any mounted read-only file system.
-group <gname> True if the file belongs to the specified group name. If <gname> is numeric and there is no such group name <gname>, it is treated as the group ID.
-user <uname> True if file belongs to the user <uname>. If <uname> is numeric and there is no such user <uname>, it is treated as the user ID.
-nouser True if the file belongs to an unknown user.
-nogroup True if the file belongs to an unknown group.
-inum n True if the file has inode number n.
-links n True if the file has n links.
-ls Always true. Prints the following file statistics: inode number, size in 512-byte blocks, file permissions, number of hard links, owner, group, size in bytes, last modification time, and filename. If the file is a symbolic link, the display of the file it is linked to is preceded by ->. The display from this ls is identical to that displayed by ls -dgils.
-ok <command> Same as -exec, except that confirmation from the user is requested before executing <command>.
-name <pattern> True if the filename contains <pattern>. Special shell pattern matching characters ([, ], *, ?) may be used as part of <pattern>. A backslash (\) is used to escape those characters to explicitly search for them as part of <pattern>.
-path <pattern> True if the pathname contains <pattern>. Special shell pattern matching characters ([, ], *, ?) may be used as part of <pattern>. A backslash (\) is used to escape those characters to explicitly search for them as part of <pattern>. Slashes (/) are treated as normal characters and do not need to be escaped.
-perm [-]<mode> <mode> may be either symbolic or octal (see chmod). If <mode> is symbolic, a starting value of zero is assumed, and <mode> sets or clears permissions without regard to the process's file mode creation mask. If mode is octal, only bits 0777 of the file's mode bits are used in the comparison. If <mode> is preceded by a dash (-), this evaluates to true if at least all the bits in <mode> are set in the file's mode bits. If <mode> is not preceded by a dash, this evaluates to true if the bits in <mode> match exactly the file's mode bits. If <mode> is symbolic, the first character may not be a dash.
-print0 Always true. Prints the current pathname followed by a null character.
-print Always true. Prints the current pathname followed by a newline character. If none of -exec, -ls, -ok, or -print0 is specified, -print is assumed.
-prune Always true. Does not descend into current file once the pattern has been matched. If -d is specified, -prune has no effect.
-size n[c] True if the file size, rounded up, is n 512-byte blocks. If c follows n, it is true if the file size is n bytes.
-type t True if the file is of the specified type. Possible file types are

W Whiteout

b Block special

c Character special

d Directory

f Regular file

l Symbolic link

p FIFO

s Socket
Operators  
Primaries may be combined using the following operators (in order of decreasing precedence):
(expression)  
 True if the parenthesized expression evaluates to true.
!expression  
 True if the expression is false (! is the unary, not the operator).
									expression [-and] expression
									expression expression
								

 True if both expressions are true. The second expression is not evaluated if the first is false. (-and is the logical AND operator.)
expression -or expression True if either expression is true. The second expression is not evaluated if the first is true. (-or is the logical OR operator.)



PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint