Commit | Line | Data |
---|---|---|
239e9d73 | 1 | .\" @(#)find.1 6.2 (Berkeley) %G% |
910ee6b3 | 2 | .\" |
17b268fb | 3 | .TH FIND 1 "" |
910ee6b3 KM |
4 | .AT 3 |
5 | .SH NAME | |
6 | find \- find files | |
7 | .SH SYNOPSIS | |
8 | .B find | |
9 | pathname-list expression | |
17b268fb KM |
10 | .br |
11 | .B find | |
12 | name | |
910ee6b3 KM |
13 | .SH DESCRIPTION |
14 | .I Find | |
15 | recursively descends | |
16 | the directory hierarchy for | |
17 | each pathname in the | |
18 | .I pathname-list | |
19 | (i.e., one or more pathnames) | |
20 | seeking files that match a boolean | |
21 | .I expression | |
22 | written in the primaries given below. | |
23 | In the descriptions, the argument | |
24 | .I n | |
25 | is used as a decimal integer | |
26 | where | |
27 | .I +n | |
28 | means more than | |
29 | .I n, | |
30 | .I \-n | |
31 | means less than | |
32 | .I n | |
33 | and | |
34 | .I n | |
35 | means exactly | |
36 | .IR n . | |
17b268fb KM |
37 | .PP |
38 | The second simplified form will list all files on the system | |
39 | whose pathname contains | |
40 | .I name. | |
41 | This is similar to | |
42 | .sp | |
43 | .ti | |
44 | find / -mtime +0 -name "*<name>*" -print | |
45 | .sp | |
46 | but much faster. | |
47 | As with | |
48 | .B -name | |
49 | below, shell syntax may be used for | |
50 | .I name. | |
910ee6b3 KM |
51 | .TP 10n |
52 | .BR \-name " filename" | |
53 | True if the | |
54 | .I filename | |
55 | argument matches the current file name. | |
56 | Normal | |
57 | Shell | |
58 | argument syntax may be used if escaped (watch out for | |
59 | `[', `?' and `*'). | |
60 | .TP | |
61 | .BR \-perm " onum" | |
62 | True if the file permission flags | |
63 | exactly | |
64 | match the | |
65 | octal number | |
66 | .I onum | |
67 | (see | |
68 | .IR chmod (1)). | |
69 | If | |
70 | .I onum | |
71 | is prefixed by a minus sign, | |
72 | more flag bits (017777, see | |
73 | .IR stat (2)) | |
74 | become significant and | |
75 | the flags are compared: | |
76 | .IR (flags&onum)==onum . | |
77 | .TP | |
78 | .BR \-type " c" | |
79 | True if the type of the file | |
80 | is | |
81 | .I c, | |
82 | where | |
83 | .I c | |
84 | is | |
17b268fb | 85 | .B "b, c, d, f, l" |
910ee6b3 | 86 | or |
17b268fb | 87 | .B s |
910ee6b3 KM |
88 | for |
89 | block special file, character special file, | |
17b268fb | 90 | directory, plain file, symbolic link, or socket. |
910ee6b3 KM |
91 | .TP |
92 | .BR \-links " n" | |
93 | True if the file has | |
94 | .I n | |
95 | links. | |
96 | .TP | |
97 | .BR \-user " uname" | |
98 | True if the file belongs to the user | |
99 | .I uname | |
100 | (login name or numeric user ID). | |
101 | .TP | |
239e9d73 S |
102 | .B \-nouser |
103 | True if the file belongs to a user | |
104 | .I not | |
105 | in the /etc/passwd database. | |
106 | .TP | |
910ee6b3 KM |
107 | .BR \-group " gname" |
108 | True if the file belongs to group | |
109 | .I gname | |
110 | (group name or numeric group ID). | |
111 | .TP | |
239e9d73 S |
112 | .B \-nogroup |
113 | True if the file belongs to a group | |
114 | .I not | |
115 | in the /etc/group database. | |
116 | .TP | |
910ee6b3 KM |
117 | .BR \-size " n" |
118 | True if the file is | |
119 | .I n | |
120 | blocks long (512 bytes per block). | |
121 | .TP | |
122 | .BR \-inum " n" | |
123 | True if the file has inode number | |
124 | .I n. | |
125 | .TP | |
126 | .BR \-atime " n" | |
127 | True if the file has been accessed in | |
128 | .I n | |
129 | days. | |
130 | .TP | |
131 | .BR \-mtime " n" | |
132 | True if the file has been modified in | |
133 | .I n | |
134 | days. | |
135 | .TP | |
136 | .BR \-exec " command" | |
137 | True if the executed command returns | |
138 | a zero value as exit status. | |
139 | The end of the command must be punctuated by an escaped | |
140 | semicolon. | |
141 | A command argument `{}' is replaced by the | |
142 | current pathname. | |
143 | .TP | |
144 | .BR \-ok " command" | |
145 | Like | |
146 | .B \-exec | |
147 | except that the generated command is written on | |
148 | the standard output, then the standard input is read | |
149 | and the command executed only upon response | |
150 | .BR y . | |
151 | .TP | |
152 | .B \-print | |
153 | Always true; | |
154 | causes the current pathname to be printed. | |
155 | .TP | |
239e9d73 S |
156 | .B \-ls |
157 | Always true; | |
158 | causes current pathname to be printed together | |
159 | with its associated statistics. | |
160 | These include (respectively) inode number, | |
161 | size in kilobytes (1024 bytes), | |
162 | protection mode, | |
163 | number of hard links, | |
164 | user, | |
165 | group, | |
166 | size in bytes, | |
167 | and modification time. | |
168 | If the file is a special file | |
169 | the size field will instead contain the major and minor | |
170 | device numbers. | |
171 | If the file is a symbolic link the | |
172 | pathname of the linked-to file is printed preceded by ``->''. | |
173 | The format is identical to that of ``ls -gilds'' | |
174 | (note however that formatting is done internally, | |
175 | without executing the ls program). | |
176 | .TP | |
910ee6b3 KM |
177 | .BR \-newer " file" |
178 | True if | |
179 | the current file has been modified more recently than the argument | |
180 | .I file. | |
239e9d73 S |
181 | .TP |
182 | .B \-xdev | |
183 | Always true; | |
184 | causes find | |
185 | .I not | |
186 | to traverse down into a file system different | |
187 | from the one on which current | |
188 | .I argument | |
189 | pathname resides. | |
910ee6b3 KM |
190 | .PP |
191 | The primaries may be combined using the following operators | |
192 | (in order of decreasing precedence): | |
193 | .TP 4 | |
194 | 1) | |
195 | A parenthesized group of primaries and operators | |
196 | (parentheses are special to the Shell and must be escaped). | |
197 | .TP 4 | |
198 | 2) | |
199 | The negation of a primary | |
200 | (`!' is the unary | |
201 | .I not | |
202 | operator). | |
203 | .TP 4 | |
204 | 3) | |
205 | Concatenation of primaries | |
206 | (the | |
207 | .I and | |
208 | operation | |
209 | is implied by the juxtaposition of two primaries). | |
210 | .TP 4 | |
211 | 4) | |
212 | Alternation of primaries | |
213 | .RB "(`" \-o "' is the" | |
214 | .I or | |
215 | operator). | |
17b268fb KM |
216 | .SH EXAMPLES |
217 | .PP | |
218 | To typeset all variants of manual pages for 'ls': | |
219 | .IP | |
220 | vtroff -man `find '*man*/ls.?'` | |
221 | .PP | |
910ee6b3 KM |
222 | To remove all files named |
223 | `a.out' or `*.o' that have not been accessed for a week: | |
224 | .IP "" .2i | |
17b268fb | 225 | find / \\( \-name a.out \-o \-name '*.o' \\) \-atime +7 \-exec rm {} \\; |
910ee6b3 KM |
226 | .SH FILES |
227 | /etc/passwd | |
228 | .br | |
229 | /etc/group | |
17b268fb KM |
230 | .br |
231 | /usr/lib/find/find.codes coded filenames | |
910ee6b3 | 232 | .SH "SEE ALSO" |
5710a779 | 233 | sh(1), test(1), fs(5) |
17b268fb KM |
234 | .br |
235 | Relevant paper in February, 1983 issue of | |
236 | .I ;login:. | |
910ee6b3 | 237 | .SH BUGS |
17b268fb | 238 | The syntax (except for the second form), is painful. |