Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ find(1) — SunOS 5.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

ls(1)

sh(1)

test(1)

stat(2)

umask(2)

environ(5)

find(1)

NAME

find − find files

SYNOPSIS

find path-name-list expression

AVAILABILITY

SUNWcsu

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.

USAGE

Expressions

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. 

−ls Always true; prints current pathname together with its associated statistics.  These include (respectively) inode number, size in kilobytes (1024 bytes), protection mode, number of hard links, user, group, size in bytes, and modification time.  If the file is a special file the size field will instead contain the major and minor device numbers.  If the file is a symbolic link the pathname of the linked-to file is printed preceded by ‘→’.  The format is identical to that of ls −gilds (see ls(1)). 
Note: Formatting is done internally, without executing the ls program. 

−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 command
True if the executed command returns a zero value as exit status.  The end of command must be punctuated by an escaped semicolon.  A command argument {} is replaced by the current path name. 

−ok command 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. 

-cpio device Always true; write the current file on device in cpio format (5120-byte records). 

-ncpio device Always true; write the current file on device in cpio -c format (5120 byte records). 

−print Always true; causes the current path name to be printed. 

−newer filename
True if the current file has been modified more recently than the argument filename.

−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.  Does not list mount points to other file systems. 

-xdev Same as the -mount option. 

−local True if the file system type is not a remote file system type as defined in the /etc/dfs/fstypes file.  nfs is used as the default remote filesystem type if the /etc/dfs/fstypes file is not present. 

( 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, c, d, l, p, or f for block special file, character special file, directory, symbolic link, fifo (named pipe), or plain file, respectively. 

−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. 

Primaries

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). 

Note:  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. 

EXAMPLES

Remove all files in your home directory named a.out or ∗.o that have not been accessed for a week:

example% find $HOME \( −name a.out −o −name ′∗.o′ \) −atime +7 −exec rm {} \;

Recursively print all file names in the current directory and below, but skipping SCCS directories:

example% find . −name SCCS −prune −o −print

Recursively print all file names in the current directory and below, skipping the contents of SCCS directories, but printing out the SCCS directory name:

example% find . −print −name SCCS −prune

ENVIRONMENT

If any of the LC_∗ variables ( LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY ) (see environ(5)) are not set in the environment, the operational behavior of find for each corresponding locale category is determined by the value of the LANG environment variable.  If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables.  If none of the above variables is set in the environment, the "C"  (U.S. style) locale determines how find behaves. 

LC_CTYPE
Determines how find handles characters. When LC_CTYPE is set to a valid value, find can display and handle text and filenames containing valid characters for that locale.  find can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide.  find can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid. 

LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses.  In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).

FILES

/etc/passwd password file

/etc/group group file

/etc/dfs/fstypes file that registers distributed file system packages

SEE ALSO

chmod(1), ls(1), sh(1), test(1), stat(2), umask(2), environ(5)

WARNINGS

The following options are obsolete and will not be supported in future releases:

-cpio device Always true; write the current file on device in cpio format (5120-byte records). 

-ncpio device Always true; write the current file on device in cpio -c format (5120 byte records). 

NOTES

When using find to determine files modified within a range of time, one must use the ?time argument BEFORE the −print argument otherwise find will give all files. 

SunOS 5.4  —  Last change: 17 Mar 1994

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026