ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahz_5.4.0.1/find.htm

383 lines
12 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content=
"text/html; charset=utf-8">
<title>find - Find files</title>
<LINK rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</HEAD>
<body bgcolor="#FFFFFF">
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h2>find - Find files</h2>
<strong>Synopsis</strong>
<p><strong>find [-H | -L | -P] [-Xdx] [-f</strong> <em>
file</em><strong>]</strong> <em>file ...</em>
[<em>expression</em>]</p>
<p><strong>Description</strong></p>
<p>The <strong>find</strong> utility recursively descends the
directory tree for each <em>file</em> listed, evaluating an <em>
expression</em> (composed of the "primaries" and "operands" listed
below) in terms of each file in the tree.</p>
<p><strong>Options</strong></p>
<dl>
<dt><strong>-H</strong></dt>
<dd>Symbolic links on the command line are followed. Symbolic links
encountered in the tree traversal are not followed. The file
information and file type returned for each symbolic link specified
on the command line is for the file referenced by the link. If the
referenced file does not exist, the file information and type will
be for the link itself.</dd>
<dt><strong>-L</strong></dt>
<dd>Both symbolic links on the command line and symbolic links
encountered in the tree traversal are followed. The file
information and file type returned for each symbolic link is for
the file referenced by the link. If the referenced file does not
exist, the file information and type will be for the link
itself.</dd>
<dt><strong>-P</strong></dt>
<dd>No symbolic links are followed. The file information and file
type returned for each symbolic link are for the link itself.</dd>
<dt><strong>-X</strong></dt>
<dd>A modification to permit <strong>find</strong> to be safely
used in conjunction with <strong>xargs</strong>. If a file name
contains any of the delimiting characters used by <strong>
xargs</strong>, a diagnostic message is displayed on standard
error, and the file is skipped. The delimiting characters include
single (') and double (") quotation marks, backslash (\), space, tab and
newline characters.</dd>
<dt><strong>-d</strong></dt>
<dd><strong>find</strong> performs a depth-first traversal. The
directories are visited in post-order and all entries in a
directory will be acted on before the directory itself. By default,
<strong>find</strong> visits directories in pre-order, or before
their contents. Note, the default is not a breadth-first
traversal.</dd>
<dt><strong>-f</strong></dt>
<dd>Specify a file hierarchy for <strong>find</strong> to traverse.
File hierarchies may also be specified as the operands immediately
following the options.</dd>
<dt><strong>-x</strong></dt>
<dd>Prevent <strong>find</strong> from descending into directories
that have a device number different than that of the file from
which the descent began.</dd>
</dl>
<strong>Primaries</strong>
<dl>
<dt><strong>-atime <em>n</em></strong></dt>
<dd>True if the difference between the file last access time and
the time <strong>find</strong> was started, rounded up to the next
full 24-hour period, is <em>n</em> 24-hour periods.</dd>
<dt><strong>-ctime <em>n</em></strong></dt>
<dd>True if the difference between the time of last change of file
status information and the time <strong>find</strong> was started,
rounded up to the next full 24-hour period, is <em>n</em> 24-hour
periods.</dd>
<dt><strong>-exec <em>utility</em> [<em>argument</em> ...]
;</strong></dt>
<dd>True if the program named <em>utility</em> returns a zero value
as its exit status. Optional arguments may be passed to the
utility. The expression must be terminated by a semicolon (;). If
the string "{}" appears anywhere in the utility name or the
arguments it is replaced by the path name of the current file. The
utility is run from the directory from which <strong>find</strong>
was run. Since the semicolon is also a special character for the shell,
you may need to escape the semicolon so it is passed as an argument
to <strong>find</strong>.</dd>
<dt><strong>-group <em>gname</em></strong></dt>
<dd>True if the file belongs to the group <em>gname</em>. If <em>
gname</em> is numeric and there is no such group name, then <em>
gname</em> is treated as a group identifier.</dd>
<dt><strong>-inum <em>n</em></strong></dt>
<dd>True if the file has inode number <em>n</em>.</dd>
<dt><strong>-links <em>n</em></strong></dt>
<dd>True if the file has <em>n</em> links.</dd>
<dt><strong>-ls</strong></dt>
<dd>This primary always evaluates to true. The following
information for the current file is written to standard output:
<ul>
<li>inode number</li>
<li>size in kilobytes</li>
<li>file permissions</li>
<li>number of hard links</li>
<li>owner</li>
<li>group</li>
<li>size in bytes</li>
<li>last modification time</li>
<li>path name</li>
</ul>
<p>If the file is a block or character special file, the major and
minor numbers will be displayed instead of the size in bytes. If
the file is a symbolic link, the path name of the linked-to file
will be displayed preceded by `-&gt;'.</p>
</dd>
<dt><strong>-mtime <em>n</em></strong></dt>
<dd>True if the difference between the file last modification time
and the time <strong>find</strong> was started, rounded up to the
next full 24-hour period, is <em>n</em> 24-hour periods.</dd>
<dt><strong>-ok <em>utility</em> [<em>argument</em>...]
;</strong></dt>
<dd>The <strong>-ok</strong> primary is identical to the <strong>
-exec</strong> primary with the exception that <strong>
find</strong> requests user affirmation for running the <em>
utility</em> by printing a message to standard error and reading a
response. If the response is other than the first character of the
YES response in the current locale, the <em>utility</em> is not run
and the value of the ok expression is false.</dd>
<dt><strong>-name <em>pattern</em></strong></dt>
<dd>True if the last component of the path name being examined
matches <em>pattern</em>. Special shell pattern matching characters
([, ], *, and ?) may be used as part of <em>pattern</em>. These
characters may be matched explicitly by escaping them with a
backslash (\).</dd>
<dt><strong>-newer <em>file</em></strong></dt>
<dd>True if the current file has a more recent last modification
time than <em>file</em>.</dd>
<dt><strong>-nouser</strong></dt>
<dd>True if the file belongs to an unknown user.</dd>
<dt><strong>-nogroup</strong></dt>
<dd>True if the file belongs to an unknown group.</dd>
<dt><strong>-path <em>pattern</em></strong></dt>
<dd>True if the path name being examined matches <em>pattern</em>.
Special shell pattern matching characters ([, ], *, and ?) may be
used as part of <em>pattern</em>. These characters may be matched
explicitly by escaping them with a backslash (\). Slashes (/) are
treated as normal characters and do not need to be matched
explicitly.</dd>
<dt><strong>-perm [-]<em>mode</em></strong></dt>
<dd>The <em>mode</em> may be either symbolic or an octal number in
the formats supported by the <a href="chmod.htm">chmod</a> command.
If the <em>mode</em> is symbolic, a starting value of zero is
assumed and the mode sets or clears permissions without regard to
the process file mode creation mask. If the <em>mode</em> is octal,
only bits 00777 (S_IRWXU | S_IRWXG | S_IRWXO) of the file's mode
bits participate in the comparison. If the <em>mode</em> is
preceded by a dash (-), this primary evaluates to true if at least
all of the bits in the mode are set in the file's mode bits. If the
<em>mode</em> is not preceded by a dash, this primary evaluates to
true if the bits in the <em>mode</em> exactly match the file's mode
bits. Note, the first character of a symbolic mode may not be a
dash (-).</dd>
<dt><strong>-print</strong></dt>
<dd>This primary always evaluates to true. It prints the path name
of the current file to standard output. The expression is appended
to the user specified expression if neither <strong>-exec</strong>,
<strong>-ls</strong> nor <strong>-ok</strong> is specified.</dd>
<dt><strong>-prune</strong></dt>
<dd>This primary always evaluates to true. It causes <strong>
find</strong> to not descend into the current file. Note, the
<strong>-prune</strong> primary has no effect if the <strong>
-d</strong> option was specified.</dd>
<dt><strong>-size <em>n[c]</em></strong></dt>
<dd>True if the file's size, rounded up, in 512-byte blocks is <em>
n</em>. If <em>n</em> is followed by <em>c</em>, then the primary
is true if the file's size is <em>n</em> bytes.</dd>
<dt><strong>-type <em>t</em></strong></dt>
<dd>True if the file is of the specified type. Possible file types
are as follows:
<ul>
<li>b for block special</li>
<li>c for character special</li>
<li>d for directory</li>
<li>f for regular file</li>
<li>l for symbolic link</li>
<li>p for FIFO</li>
<li>s for socket</li>
</ul>
</dd>
<dt><strong>-user <em>uname</em></strong></dt>
<dd>True if the file belongs to the user <em>uname</em>. If <em>
uname</em> is numeric and there is no such user name, then <em>
uname</em> is treated as a user identifier.</dd>
</dl>
<p>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".</p>
<p><strong>Operators</strong></p>
<p>The primaries may be combined using the following operators. The
operators are listed in order of decreasing precedence.</p>
<dl>
<dt><strong>(expression)</strong></dt>
<dd>This evaluates to true if the parenthesized expression
evaluates to true.</dd>
<dt><strong>!expression</strong></dt>
<dd>This is the unary NOT operator. It evaluates to true if the
expression is false.</dd>
<dt><strong>expression -and expression</strong></dt>
<dd>The -and operator is the logical AND operator. As it is implied
by the juxtaposition of two expressions it does not need to be
specified. The expression evaluates to true if both expressions are
true. The second expression is not evaluated if the first
expression is false.</dd>
<dt><strong>expression -or expression</strong></dt>
<dd>The -or operator is the logical OR operator. The expression
evaluates to true if either the first or the second expression is
true. The second expression is not evaluated if the first
expression is true.</dd>
</dl>
<p>All operands and primaries must be separate arguments to the
<strong>find</strong> utility. Primaries which themselves take
arguments expect each argument to be a separate argument to
<strong>find</strong>. <strong>Notes</strong></p>
<ol>
<li>The special characters used by <strong>find</strong> are also
special characters to many shell programs. In particular, the
characters *, [, ], ?, (, ), !, and ; may need to be escaped from
the shell.</li>
</ol>
<p><strong>Exit Status</strong></p>
<ul>
<li>0 on success</li>
<li>&gt;0 if an error occurs</li>
</ul>
<p><strong>Related information</strong></p>
<ul>
<li><a href="chmod.htm">chmod - Change file modes</a></li>
<li><a href="fileutil.htm">file - Determine file type</a></li>
<li><a href="xargs.htm">xargs - Construct argument lists and invoke
utility</a></li>
</ul>
<strong>Examples</strong>
<ol>
<li>Find all *.class files starting at the directory
"/project/java/class".
<pre>
find /project/java/class -name '*.class'
</pre>
</li>
<li>Find all the *.java files that have the "import java.awt;"
string in them starting at the directory, "/project/java/code".
<pre>
find /project/java/code -name '*.java' -exec grep 'import java.awt;' {} \;
</pre>
</li>
<li>Find all the *.class files starting at the directory "/project/java/class" and
remove the files.
<pre>
find /project/java/class -name '*.class' -exec rm {} \;
</pre>
</li>
<li>Find all the files that belong to the user "abbey" starting at
the directory, "/project".
<pre>
find /project -user abbey
</pre>
</li>
</ol>
<!-- end ibmbody========================================================= -->
</body>
</html>