find.1 - sbase - suckless unix tools
(HTM) git clone git://git.suckless.org/sbase
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
find.1 (3655B)
---
1 .Dd July 30, 2025
2 .Dt FIND 1
3 .Os sbase
4 .Sh NAME
5 .Nm find
6 .Nd find files
7 .Sh SYNOPSIS
8 .Nm
9 .Op Fl H | L
10 .Ar path Op ...
11 .Op Ar expression
12 .Sh DESCRIPTION
13 .Nm
14 walks a file hierarchy starting at each
15 .Ar path
16 and applies the
17 .Ar expression
18 to each file encountered.
19 .Sh OPTIONS
20 .Bl -tag -width Ds
21 .It Fl H
22 Dereference symbolic links provided as
23 .Ar path .
24 .It Fl L
25 Dereference all symbolic links encountered.
26 .El
27 .Sh EXTENDED DESCRIPTION
28 .Ar expression
29 is a combination of the following primaries and boolean operators.
30 In the following descriptions the number n can be replaced by +n, n, or
31 -n, to mean more than, exactly, or less than n respectively.
32 .Ss Primaries
33 .Bl -tag -width Ds
34 .It Fl name Ar pattern
35 True if the name of the file matches the given pattern.
36 .It Fl path Ar pattern
37 True if the path to the file matches the given pattern.
38 .It Fl nouser
39 True if the file belongs to a user for which
40 .Xr getpwuid 3
41 returns NULL.
42 .It Fl nogroup
43 True if the file belongs to a group for which
44 .Xr getgrgid 3
45 returns NULL.
46 .It Fl xdev
47 True.
48 Do not enter directory on a different device.
49 .It Fl prune
50 True.
51 Do not enter directory.
52 .It Fl perm Ar mode
53 True if permissions on the file match mode.
54 Mode is a symbolic mode as used in chmod.
55 A leading '-' in mode checks that at least all bits in mode are set in
56 permissions for file.
57 Without the leading '-' the permissions for file must exactly match
58 mode.
59 .It Fl type Ar t
60 True if file is of type specified by
61 .Ar t .
62 .Bl -tag -width Ds
63 .It Ar b
64 block special
65 .It Ar c
66 character special
67 .It Ar d
68 directory
69 .It Ar l
70 symbolic link
71 .It Ar p
72 FIFO
73 .It Ar f
74 regular file
75 .It Ar s
76 socket
77 .El
78 .It Fl links Ar n
79 True if file has
80 .Ar n
81 links.
82 .It Fl user Ar name
83 True if file belongs to user
84 .Ar name .
85 .It Fl group Ar name
86 True if file belongs to group
87 .Ar name .
88 .It Fl size Ar n[c]
89 True if file size in 512 byte sectors (rounded up), or bytes (if
90 .Ar c
91 is given), is
92 .Ar n .
93 .It Fl atime n
94 True if file access time is
95 .Ar n
96 days.
97 .It Fl ctime
98 True if file status change time is
99 .Ar n
100 days.
101 .It Fl mtime
102 True if file modified time is
103 .Ar n
104 days.
105 .It Fl exec Ar cmd [arg ...] \&;
106 Execute cmd with given arguments, replacing each {} in argument list
107 with the current file.
108 True if cmd exits with status 0.
109 .It Fl exec Ar cmd [arg ...] {} +
110 True.
111 Add as many files as possible to argument list and execute when the list
112 is full or all files have been found.
113 .It Fl ok Ar cmd [arg ...] \&;
114 Prompt the user on each file encountered whether or not to execute cmd
115 as with -exec.
116 True if the user responds yes and cmd exits with status 0, false
117 otherwise.
118 .It Fl print
119 True.
120 Print the current pathname followed by a newline ('\en') character.
121 .It Fl print0
122 True.
123 Print the current pathname followed by a NUL ('\e0') character.
124 .It Fl newer Ar file
125 True if the modification time of the current file is newer than that of
126 the provided file.
127 .It Fl depth
128 True.
129 Causes find to evaluate files within in a directory before the directory
130 itself.
131 .El
132 .Ss Operators
133 In order of decreasing precedence
134 .Bl -tag -width Ds
135 .It Ar \&( expression \&)
136 True if expression is true.
137 .It Ar \&! expression
138 True if expression if false.
139 .It Ar expression [ Fl a ] Ar expression
140 True if both expressions are true.
141 Second expression is not evaluated if first expression is false.
142 .Fl a
143 is implied if there is no operator between primaries.
144 .It Ar expression Fl o Ar expression
145 True if either expression is true.
146 Second expression is not evaluated if first expression is true.
147 .El
148 .Pp
149 If no expression is supplied, -print is used.
150 If an expression is supplied but none of -print, -exec, or -ok is
151 supplied, then -a -print is appended to the expressions.