FIND(1-SysV) RISC/os Reference Manual FIND(1-SysV)
NAME
find - find files
SYNOPSIS
find path-name-list expression
DESCRIPTION
find is used to locate files or directories. find can print
the path name of a file, check for files of certain size or
check for files that belong to a certain user. It begins
searching at the directory or file that you list on the com-
mand line. Which files it locates, and the action it takes
when it finds them, are both determined by the logical
expression. find recursively descends the directory hierar-
chy for each path name in the path-name-list (that is, one
or more path names) seeking files that match the specified
parameters. 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. Valid parameters are:
-name file Searches for the current file name that
matches file. Normal shell argument syntax
may be used if escaped (watch out for [, ?
and *).
[-perm] -onum Searches for files that 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 evalu-
ates true if they match.
-type c Searches for files of the type c, where c is
one of the following:
b block special file
c character special file
d directory
f plain file
l symbolic link
p fifo (aka, named pipe)
s socket
-links n Searches for files with n links.
-user uname Searches for files belonging 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 Searches for a file belonging to the group
gname. If gname is numeric and does not
Printed 1/15/91 Page 1
FIND(1-SysV) RISC/os Reference Manual FIND(1-SysV)
appear in the /etc/group file, it is taken as
a group ID.
-size n[c] Searches for a file n blocks long (512 bytes
per block). If n is followed by a c, the
size is in characters.
-atime n Searches for files that have been accessed in
n days. The access time of directories in
path-name-list is changed by find itself.
-mtime n Searches for files modified in n days.
-ctime n Searches for files created in n days.
-exec cmd Executes cmd. This returns a zero value as
exit status. The end of cmd must be punc-
tuated by an escaped semicolon. 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 Prints the current path names of files found.
-cpio device Write the current file on device in cpio(1)
format (5120-byte records).
-newer file The current file has been modified more
recently than the argument file.
-depth 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 Restricts the search to the file system con-
taining the directory specified, or if no
directory was specified, the current direc-
tory.
-local The file physically resides on the local sys-
tem. The option prevents searches from des-
cending into NFS (Network File System) file
systems.
-follow Causes find to traverse symbolic links to
Page 2 Printed 1/15/91
FIND(1-SysV) RISC/os Reference Manual FIND(1-SysV)
directories. Normally find does not traverse
symbolic links.
( expression ) The parenthesized expression is true
(parentheses are special to the shell and
must be escaped).
The primaries may be combined using the following operators
(in order of decreasing precedence):
1) The negation of a primary (! is the unary not opera-
tor).
2) Concatenation of primaries (the and operation is implied
by the juxtaposition of two primaries).
3) Alternation of primaries (-o is the or operator).
EXAMPLE
find . -print
Prints the relative path names of all files and directories,
and their subdirectories in the current working directory.
find $HOME -user xyz -exec chmod 771 {} \;
Changes the permissions for all files in your HOME directory
that are owned by the user "xyz" to "771", which is read,
write, and execute permission for the owner and group, and
execute permission for the other users.
find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm
{} \;
Removes all files named a.out or *.o that have not been
accessed for a week.
FILES
/etc/passwd
/etc/group
SEE ALSO
chmod(1), cpio(1), sh(1), test(1).
stat(2), umask(2), fs.ffs(4) in the Programmer's Reference
Manual.
ERRORS
find / -depth always fails with the message: ``find: stat
failed: : No such file or directory''.
Printed 1/15/91 Page 3