find(1) DG/UX R4.11 find(1)
NAME
find - find files
SYNOPSIS
find path-name-list expression
DESCRIPTION
find recursively descends the directory hierarchy for each path name
in the path-name-list (that is, 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 used as 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. Valid expressions are:
-name pattern True if pattern matches the current file name.
Normal shell file name generation characters (see
sh(1)) may be used. A backslash (\) is used as an
escape character within the pattern. The pattern
should be escaped or quoted when find is invoked from
the shell.
-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 that are
set in onum are compared with the file permission
flags, and the expression evaluates true if they
match.
-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's data was modified n days ago.
-ctime n True if the file's status was 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 space-
semicolon. To keep the shell from interpreting this
semicolon as the end of your command line, you should
precede it with a backslash (see example). A command
argument {} is replaced by the current path name.
-ok cmd Like -exec except that 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; causes the current path name to be
printed.
-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 directory specified.
-local True if the file physically resides on the local
system.
( expression ) True if the parenthesized expression is true
(parentheses are special to the shell and must be
escaped).
-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
-follow Always true; causes symbolic links to be followed.
When following symbolic links, find keeps track of
the directories visited so that it can detect
infinite loops; for example, such a loop would occur
if a symbolic link pointed to an ancestor. This
expression should not be used with the -type l
expression.
-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.
-nouser True if the file belongs to a user not in the
/etc/passwd file.
-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.
-nogroup True if the file belongs to a group not in the
/etc/group file.
-fstype type True if the filesystem to which the file belongs is
of type type.
-inum n True if the file has inode number n.
-prune Always yields true. Do not examine any directories
or files in the directory structure below the pattern
just matched. See the examples, below.
The primaries may be combined 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 false.
Note that when you use find in conjunction with cpio, if you use the
-L option with cpio then you must use the -follow expression with
find and vice versa. Otherwise there will be undesirable results.
International Features
find can process characters from supplementary code sets in addition
to ASCII characters. Searches are performed on characters, not
individual bytes.
Characters from supplementary code sets can be used in path-name-
list.
Expressions:
-name file
Characters from supplementary code sets can be used in file.
-exec cmd
-ok cmd
Characters from supplementary code sets can be used in cmd.
EXAMPLES
$ find . -perm 777 -print
./a.out
./edscript
./shellscript
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. Note the backslash that precedes
the semicolon terminating the rm command.
$ find . -perm 0777 -o -print
The name of each file whose permissions are not 0777 is printed.
$ find . -name a.out -print
./a.out
The above example searches the working directory and all directories
below it for a specific file.
$ find / -name passwd -print
/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.
$ find $HOME \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;
The above example removes all files in your home directory named
a.out or *.o that have not been accessed for a week.
$ find . -name SCCS -prune -o -print
The above example recursively prints all file names in the current
directory and below, but skipping SCCS directories.
$ find . -print -name SCCS -prune
The above example recursively prints all file names in the current
directory and below, skipping the contents of SCCS directories, but
printing out the SCCS directory name.
FILES
/etc/passwd, /etc/group.
SEE ALSO
chmod(1), cpio(1), sh(1), test(1).
stat(2), cpio(4), fs(4).
NOTES
When using find to determine files modified within a range of time,
one must use the -mtime argument BEFORE the -print argument otherwise
find will give all files.
The n argument to -atime, -mtime and -ctime is specified in units of
days, but a day is calculated as starting 24 hours from the current
time. Therefore, if it is 09:00 Friday, "-mtime 0" will be true for
any files modified after 09:00 Thursday, not just for those files
modified after 00:00 Friday.
WARNING
The following option is obsolete and will not be supported in future
releases.
-cpio device Always true; write the current file on device in
cpio(1) format (512-byte records).
Licensed material--property of copyright holder(s)