FIND Command

HSI Version: 

All

Purpose: 

Find recursively descends the directory hierarchy for each pathname in the pathname-list, seeking files that match a boolean (logical) 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. 

Aliases: 

 

Command Format: 

find pathname-list expression

Options: 

-cos cosid
True only for plain files whose Class of Service ID matches that specified by cosid


-name filename
True if the filename argument matches the current file name. Wildcard characters are allowed, with or without surrounding quotes ("" or '').

-perm onum
True if the file permission flags exactly match the octal number onum. Only the lowest 3 octal digits are significant.

-prune
Always yields true. Has the side effect of pruning the search tree at the file. That is, if the current path name is a directory, find will not descend into that directory.


-type c
True if the type of the file is c, where c is one of: 

d for directory,
f for plain file,
l for symbolic link


-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 HPSS passwd database, it is taken as a user ID.

-nouser
True if the file belongs to a user not in the passwd database.

-group gname
True if the file belongs to group gname. If gname is numeric and does not appear as a login name in the HPSS group database, it is taken as a group ID.

-nogroup
True if the file belongs to a group not in the group database.


-size [+|-n

If "+" is specified, true if the filesize is > n bytes

if "-" is specified, true if the filesize is < n bytes,
Otherwise, true if the file is exactly n bytes

-atime n
True if the file has been accessed in n days. Note that the access time of directories in path-name-list is changed by the find command.

-mtime n
True if the file has been modified in n days.

-ctime n
True if the file has been changed in n days. "Changed" means that the file's "time of last metadata update" field has changed.

-print
Always true; the current pathname is printed.

-ls
Always true; causes current pathname to be printed together with its associated statistics. These include (respectively) inode number, size in kilobytes (1024 bytes), protection mode, user, group, size in bytes, and modification time. If the file is a symbolic link the pathname of the linked-to file is printed preceded by ``->''.

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


Options to be added later:

-exec command (DEFERRED - intended for use 'get/put', etc)
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 pathname.

-ok command (DEFERRED)
Like -exec except that the generated command is written on the standard output, then the standard input is read and the command executed only upon response y.

Keywords: 

 

Usage Notes: 

 

Example: 

find . /usr/local/bin -name *.doc -print

Related Command(s):