/
find.1
168 lines (168 loc) · 2.8 KB
/
find.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
.th FIND I 5/15/74
.sh NAME
find \*- find files
.sh SYNOPSIS
.bd find
pathname expression
.sh DESCRIPTION
.it Find
recursively descends
the directory hierarchy from
.it pathname
seeking files that match a boolean
.it expression
written in the primaries given below.
In the descriptions, the argument
.it n
is used as a decimal integer
where
.it +n
means more than
.it n,
.it \*-n
means less than
.it n
and
.it n
means exactly
.it n.
.s3
.lp +16 16
\fB\*-name\fR filename True if the
.it filename
argument matches the current file name.
Normal
.it Shell
argument syntax may be used if escaped (watch out for
`[', `?' and `*').
.s3
.lp +16 16
\fB\*-perm\fR onum \c
True if the file permission flags
exactly
match the
octal number
.it onum
(see chmod(I)).
If
.it onum
is prefixed by a minus sign,
more flag bits (017777, see stat(II)) become significant and
the flags are compared:
.it "(flags&onum)==onum."
.s3
.lp +16 16
\fB\*-type\fI c\fR True if the type of the file
is
.it c,
where
.it c
is
.bd "b, c, d"
or
.bd f
for
block special file, character special file,
directory or plain file.
.s3
.lp +16 16
\fB\*-links\fI n\fR \c
True if the file has
.it n
links.
.s3
.lp +16 16
\fB\*-user\fR uname \c
True if the file belongs to the user
.it uname.
.s3
.lp +16 16
\fB\*-group\fR gname \c
As it is for
.bd \*-user
so shall it be for
.bd \*-group
(someday).
.s3
.lp +16 16
\fB\*-size\fI n\fR \c
True if the file is
.it n
blocks long (512 bytes per block).
.s3
.lp +16 16
\fB\*-atime\fI n\fR \c
True if the file has been accessed in
.it n
days.
.s3
.lp +16 16
\fB\*-mtime\fI n\fR \c
True if the file has been modified in
.it n
days.
.s3
.lp +16 16
\fB\*-exec\fR command \c
True if the executed command returns
exit status zero
(most commands do).
The end of the command is punctuated by an escaped
semicolon.
A command argument `{}' is replaced by the
current pathname.
.s3
.lp +16 16
\fB\*-ok\fR command \c
Like
.bd \*-exec
except that the generated command line is printed
with a question mark first,
and is executed only if the user responds
\fBy\fR.
.s3
.lp +16 16
\fB\*-print\fR \c
Always true;
causes the current pathname to be printed.
.s3
.i0
The primaries may be combined with
these operators
(ordered by precedence):
.s3
.lp +16 16
\fB!\fR prefix
.it not
.s3
.lp +16 16
\fB\*-a\fR infix
.it and,
second operand evaluated only if first is true
.s3
.lp +16 16
\fB\*-o\fR infix
.it or,
second operand evaluated only if first is false
.s3
.lp +16 16
\fB( \fRexpression\fB )\fR parentheses for grouping.
(Must be escaped.)
.s3
.i0
To remove files named
`a.out' and `*.o' not accessed for a week:
.s3
.lp +.5i 0
find / "(" \*-name a.out \*-o \*-name "*.o" ")"
\*-a \*-atime +7 \*-a \*-exec rm {} ";"
.i0
.sh FILES
/etc/passwd
.sh "SEE ALSO"
sh (I), if(I), file system (V)
.sh BUGS
There is no way to check device type.
.br
Syntax should be reconciled with
.it if.