find(1)
_________________________________________________________________
find Command
find files
_________________________________________________________________
SYNTAX
find path-name-list expression
DESCRIPTION
Find recursively descends the directory hierarchy for each path
name in the path-name-list (i.e., one or more path names) seeking
files that match a boolean expression written in the primaries
given below. In the descriptions, the argument n is a decimal
integer where +n means more than n, -n means less than n and n
means exactly n.
Arguments that are normally numeric are terminated by the first
non-numeric character in the argument, and the remaining
characters are ignored. If the argument's first character is not
numeric, the argument is considered equivalent to 0.
-name file True if file matches the current file name.
Normal shell argument syntax may be used if
escaped (watch out for [, ? and *).
-perm onum True if the file permission flags exactly match
the octal number onum (see chmod(1)). If onum is
prefixed by a minus sign, only the bits set in
onum are compared to permission flags. If the
bits and the permission flags match, then -perm
evaluates to true.
-type c True if the type of the file is c, where c is
b block special file
c character special file
d directory
p fifo (named pipe)
f plain file
l symbolic link file
s socket files in the AF _UNIX domain
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
find(1)
-links n True if the file has n links.
-user uname True if the file belongs to the user uname. If
uname is numeric and does not appear as a login
name in the /etc/passwd file, it is taken as a
user ID.
-group gname True if the file belongs to the group gname. If
gname is numeric and does not appear in the
/etc/group file, it is taken as a group ID.
-size n[c] True if the file is n blocks long (512 bytes per
block). If n is followed by a c, the size is in
characters.
-atime n True if the file was accessed n days ago. The
access time of directories in path-name-list is
changed by find itself.
-mtime n True if the file was modified n days ago.
-ctime n True if the file changed n days ago.
-exec cmd; True if the executed cmd returns a zero value as
exit status. The end of cmd is indicated by the
escaped semicolon. A command argument {} is
replaced by the current path name.
-ok cmd Like -exec , but the generated command line is
printed with a question mark first, and is
executed only if the user responds by typing y.
-print Always true; prints the current pathname.
-cpio device Always true; write the current file on device in
cpio(4) format (5120-byte records).
-newer file True if the current file has been modified more
recently than the argument file.
-depth Always true; causes descent of the directory
hierarchy to be done so that all entries in a
directory are acted on before the directory
itself. This can be useful when find is used
with cpio(1) to transfer files that are contained
in directories without write permission.
-mount Always true; restricts the search to the file
system containing the pathname in the pathname
list.
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)
find(1)
-local True if the file physically resides on the local
system.
( expression ) True if the expression is true (parentheses are
special to the shell and must be escaped).
You can combine the primaries using the following operators (in
order of decreasing precedence):
1) The negation of a primary (! is the unary not operator).
2) Concatenation of primaries (the and operation is implied by
the juxtaposition of two primaries).
3) Alternation of primaries (-o is the or operator).
Only those primaries necessary to establish whether the
expression is true or false are evaluated. Thus, for an
expression concatenating two primaries, the second primary is
evaluated only if the first primary is true. For an expression
alternating two primaries, the second primary is evoked only if
the first primary is true.
_________________________________________________________________
EXAMPLES
$ find . -perm 777 -print
The above example searches the working directory and all
directories below the working directory for files with read,
write, and execute permission for owner, group, and others.
$ find . print -perm 0777 -exec rm {} ;
The name of every file below `.' is printed. Those files whose
permissions are 0777 are deleted.
$ find . -perm 0777 -o -print
The name of each file whose permissions are not 0777 is printed.
$ find . -name a.out -print
The above example searches the working directory and all
directories below it for a specific file.
$ find / -name passwd -print
DG/UX 4.00 Page 3
Licensed material--property of copyright holder(s)
find(1)
/bin/passwd
/etc/passwd
/usr/etc/yp/src/passwd
The above example searches for the passwd file starting from the
root directory. In this case, three different passwd files were
found in different directories.
_________________________________________________________________
FILES
/etc/passwd, /etc/group
SEE ALSO
chmod(1), cpio(1), sh(1), test(1).
stat(2), cpio(4), fs(4) in the Programmer's Reference for the
DG/UX System
DG/UX 4.00 Page 4
Licensed material--property of copyright holder(s)