1FIND(1)                     General Commands Manual                    FIND(1)
2
3
4

NAME

6       find - find files
7

SYNOPSIS

9       find pathname-list expression
10       find pattern
11

DESCRIPTION

13       In  the first form above, find recursively descends the directory hier‐
14       archy for each pathname in the pathname-list (i.e., one or  more  path‐
15       names)  seeking  files  that  match a boolean expression written in the
16       primaries given below.  In the descriptions, the argument n is used  as
17       a  decimal integer where +n means more than n, -n means less than n and
18       n means exactly n.
19
20       The second form rapidly searches a database  for  all  pathnames  which
21       match  pattern.  Usually the database is recomputed weekly and contains
22       the pathnames of all files which are publicly accessible.  If  escaped,
23       normal shell “globbing” characters (`*', `?', `[', and ']') may be used
24       in pattern, but the matching differs in that no characters  (e.g.  `/')
25       have  to  be  matched  explicitly.  As a special case, a simple pattern
26       containing no globbing characters is matched as though  it  were  *pat‐
27       tern*; if any globbing character appears there are no implicit globbing
28       characters.
29
30       -name filename
31                 True if the filename argument matches the current file  name.
32                 Normal  shell  argument  syntax may be used if escaped (watch
33                 out for `[', `?' and `*').
34
35       -perm onum
36                 True if the file permission flags  exactly  match  the  octal
37                 number  onum  (see chmod(1)).  If onum is prefixed by a minus
38                 sign, more flag bits (017777, see stat(2)) become significant
39                 and the flags are compared: (flags&onum)==onum.
40
41       -type c   True  if  the type of the file is c, where c is b, c, d, f, l
42                 or s for block special file, character special  file,  direc‐
43                 tory, plain file, symbolic link, or socket.
44
45       -links n  True if the file has n links.
46
47       -user uname
48                 True  if  the  file  belongs to the user uname (login name or
49                 numeric user ID).
50
51       -nouser   True if the file belongs to a user  not  in  the  /etc/passwd
52                 database.
53
54       -group gname
55                 True  if  the  file  belongs  to  group  gname (group name or
56                 numeric group ID).
57
58       -nogroup  True if the file belongs to a group  not  in  the  /etc/group
59                 database.
60
61       -size n   True if the file is n blocks long (512 bytes per block).
62
63       -inum n   True if the file has inode number n.
64
65       -atime n  True if the file has been accessed in n days.
66
67       -mtime n  True if the file has been modified in n days.
68
69       -exec command
70                 True  if  the  executed  command returns a zero value as exit
71                 status.  The end of the command  must  be  punctuated  by  an
72                 escaped  semicolon.   A  command argument `{}' is replaced by
73                 the current pathname.
74
75       -ok command
76                 Like -exec except that the generated command  is  written  on
77                 the  standard output, then the standard input is read and the
78                 command executed only upon response y.
79
80       -print    Always true; causes the current pathname to be printed.
81
82       -ls       Always true; causes current pathname to be  printed  together
83                 with its associated statistics.  These include (respectively)
84                 inode number, size  in  kilobytes  (1024  bytes),  protection
85                 mode,  number  of hard links, user, group, size in bytes, and
86                 modification time.  If the file is a special  file  the  size
87                 field  will  instead  contain the major and minor device num‐
88                 bers.  If the file is a symbolic link  the  pathname  of  the
89                 linked-to  file is printed preceded by ``->''.  The format is
90                 identical to that of ``ls -gilds'' (note however that format‐
91                 ting is done internally, without executing the ls program).
92
93       -newer file
94                 True if the current file has been modified more recently than
95                 the argument file.
96
97       -cpio file
98                 Write the current file on the argument file in cpio format.
99
100       -xdev     Always true; causes find not to traverse  down  into  a  file
101                 system different from the one on which current argument path‐
102                 name resides.
103
104       The primaries may be combined using the following operators  (in  order
105       of decreasing precedence):
106
107       1)  A  parenthesized  group of primaries and operators (parentheses are
108           special to the Shell and must be escaped).
109
110       2)  The negation of a primary (`!' is the unary not operator).
111
112       3)  Concatenation of primaries (the and operation  is  implied  by  the
113           juxtaposition of two primaries).
114
115       4)  Alternation of primaries (`-o' is the or operator).
116

EXAMPLES

118       To find all accessible files whose pathname contains `find':
119
120              find find
121
122       To typeset all variants of manual pages for `ls':
123
124              vtroff -man `find '*man*/ls.?'`
125
126       To  remove all files named `a.out' or `*.o' that have not been accessed
127       for a week:
128
129         find / \( -name a.out -o -name '*.o' \) -atime +7 -exec rm {} \;
130

FILES

132       /etc/passwd
133       /etc/group
134       /var/db/find.codes     coded pathnames database
135

SEE ALSO

137       sh(1), test(1), fs(5)
138       Relevant paper in February, 1983 issue of ;login:.
139

BUGS

141       The first form's syntax is painful, and the second form's exact  seman‐
142       tics is confusing and can vary from site to site.
143
144       More than one `-newer' option does not work properly.
145
146
147
1487th Edition                    October 11, 1996                        FIND(1)
Impressum