Find Command Builder
Describe what you are looking for and get the find command, with every predicate explained and the destructive actions marked.
Find command builder
find command
BSD and GNU find (verified on BSD)find . -name '*.log' -type f -mtime -1 -print
The command this form describes, quoted for POSIX sh, bash and zsh. Nothing runs here — a browser cannot reach your filesystem.
Every building block, recipe and example on this page was verified against BSD find on macOS by executing it; forms that only GNU findutils accepts are labelled GNU and cite the manual instead.
Notes
- Code W_NAME_UNQUOTED_GLOBThe pattern *.log is emitted in single quotes: left bare, the shell would expand it against the current directory before find ever ran.
- Code N_MTIME_ROUNDS_DOWN-mtime counts whole 24-hour periods with the fraction rounded down — -mtime -1 means modified within the last 24 hours, and -mmin is the unit for anything finer.
What each part does
One entry per emitted part, in command order. Each line is this page's own summary and links to the manual it was checked against.
find- Walks the directory tree under each start path and applies the tests to every entry. manual — find
.- The start directory. Everything below it is visited unless a depth limit says stop. manual — path
-name '*.log'- Glob match against the file name only — the last path component, never the directories above it. manual — -name
-type f- Keep one kind of entry: f file, d directory, l symlink, s socket, p pipe, b or c device. manual — -type
-mtime -1- Modification age in whole 24-hour periods, fraction rounded down; -1 means within the last day. manual — -mtime
-print- Prints each match, one per line — also what find does when no action is written. manual — -print
BSD vs GNU find
| Where they differ | BSD find | GNU findutils |
|---|---|---|
| -printf exists only on GNU | find: -printf: unknown primary or operator Executed | -printf '%p\n' Cited |
| Any-of-these-bits permission spelling | -perm +644 Executed | -perm /644 Cited |
| Switching on extended regex | find -E … -regex '…' Executed | find … -regextype posix-extended -regex '…' Cited |
| What -size -1k matches | -size -1k matches 0–1023 bytes (exact bytes per unit) Executed | -size -1k matches only empty files (rounds up per unit) Cited |
| Where depth limits may sit | find . -name '*.log' -maxdepth 1 (accepted, empty stderr) Executed | warns unless -maxdepth precedes other tests Cited |
Recipes
| Task | find command | Verified | Load |
|---|---|---|---|
| Log files modified in the last 24 hours | find . -name '*.log' -type f -mtime -1 -print | Executed | |
| Empty directories, top level only | find . -maxdepth 1 -type d -empty -print | Executed | |
| A file by name, any capitalisation | find src -iname 'A.TXT' -print | Executed | |
| Files whose whole path matches a pattern | find . -path '*/deep/*' -type f -print | Executed | |
| Files with at least mode 644 | find src -type f -perm -644 -print | Executed | |
| Pipe matches to another command, safely | find . -name '*.txt' -print0 | xargs -0 echo GOT | Executed | |
| Run one command over all matches | find src -name '*.txt' -exec echo FOUND {} + | Executed | |
| Delete matching files (dry run in the warning card) | find . -maxdepth 1 -name 'del.tmp' -delete | Executed |
What this page will not do
It never runs the search — no filesystem exists in a browser — and it never sends what you type anywhere: the form is kept only on this device, in this browser. locate, fd and ripgrep are different tools; -printf, -newerXY, -prune and -execdir are out of this version on purpose; PowerShell and cmd.exe quoting are not covered.
Command written — 6 parts.
Do it offline:$ find . -name '*.log' -type f
How to use it
- Set the start directory, and, if you need them, a depth window or a symlink rule. Depth limits are written straight after the directory, where both dialects honour them.
- Describe the match: glob patterns for the file name or whole path, a kind, modified time in days or minutes, a size, an octal mode, an owner or group. Each field takes up to 4,096 characters.
- Invert any test with NOT, or join several with OR — the escaped parentheses that -o needs are written for you.
- Choose what happens to matches, safest first: print, a NUL-safe xargs pipe, per-file or batched -exec, an ls listing, or -delete — which raises a warning card with the print form to run first.
- Copy the command, download it as a .sh snippet, or share the form as a link — the whole form is settings, so a link carries all of it.
Say what you are looking for — a name pattern, a kind, an age, a size, an owner — and the matching find command assembles as you pick, each part explained below. Actions are ordered by blast radius, -delete sits last behind a dry-run, and nothing is ever searched here: a browser cannot see your filesystem, so the command is built for your terminal to run.
Examples
Log files modified in the last 24 hoursfind . -name '*.log' -type f -mtime -1 -print-mtime counts whole 24-hour periods rounded down, so -1 means the last day; executed, it kept the fresh logs and dropped one dated 2020. The pattern rides in single quotes so the shell cannot expand it first.
Text files by name OR anything under deep/find . \( -name '*.txt' -o -path '*/deep/*' \) -type f -print-o binds looser than the AND joining tests written side by side, so without the escaped parentheses -type f would govern the second branch only. The builder writes \( … \) whenever OR is in play.
One command over every match, batched — proven with echofind src -name '*.txt' -exec echo FOUND {} +The + terminator hands many paths to ONE invocation — executed, two matches came back as a single FOUND line, where the \; form printed one line per file. The + needs {} directly before it.
Delete stray del.tmp, top level onlyfind . -maxdepth 1 -name 'del.tmp' -deleteExecuted for real on the golden host: silent output, file gone. -delete walks depth-first and its depth limit must come first, so -maxdepth is emitted straight after the start directory; the -print twin sits in the warning card beside it.
Every example on this page is executed against the same engine that powers the tool, on every build.
Gotchas worth knowing
A day is a rounding rule
find divides a file's age by 24 hours and discards the fraction before comparing, so a 30-hour-old file has an -mtime of exactly 1. Reach for -mmin when the window is tighter than a day.
-size -1k is two different file sets
BSD find compares suffixed sizes in exact bytes — executed, -size -1k matched the 6-byte and 1023-byte fixtures, not the 1024-byte one. GNU findutils rounds size UP to the next whole unit first, so there -size -1k matches only empty files. With no letter both count 512-byte blocks, rounded up.
Patterns are quoted before your shell can eat them
An unquoted *.log is expanded by the shell against the current directory before find starts, silently rewriting the search. Every pattern here rides in single quotes; -name covers the file name, -path the whole printed path.
Two actions survive hostile file names
Newlines and spaces are legal in names, so only the NUL-separated -print0 | xargs -0 pipe and -exec's direct argument passing keep them intact. {} + batches many paths per call; {} \; pays one process per file.
BSD and GNU find are near neighbours, not twins
The golden host's BSD find refused -printf with 'find: -printf: unknown primary or operator' — that flag is GNU-only. Any-bits -perm is +644 on BSD, /644 on GNU; extended regex is find -E on BSD, -regextype posix-extended on GNU.
Out of scope, on purpose
This page never runs the search — no filesystem exists in a browser — and sends nothing you type anywhere; the form stays on this device. locate, fd and ripgrep are different tools; -printf, -newerXY, -prune and -execdir are out of this version; PowerShell and cmd.exe quoting is not covered.
Common errors
The start directory is empty — find needs a path to walk. Use . for the current directory.- Clearing the one required field; a dot searches from wherever the terminal is standing.
"yesterday" is not a whole number of days — -mtime takes a count like 1; the sign picker supplies the - or +.- Words where find wants a number; within-a-day is the -1 spelling, a sign plus a count.
"rwx" is not an octal mode — -perm takes one to four octal digits (0–7), like 644 or 4755.- Symbolic rwx letters belong to another notation; this field takes octal digits.
-mindepth 2 is deeper than -maxdepth 1 — no level satisfies both. Lower -mindepth or raise -maxdepth.- A depth window that excludes every level refuses instead of matching nothing.
The -exec action has no command to run — enter one, or pick a printing action instead.- -exec with nothing to execute is not a command; the refusal points at the safe default.
The name pattern is 4097 characters — this builder accepts up to 4096 per field.- Cap and actual both come from the engine's constants, so the message can never drift from what is enforced.
FAQ
Why can this page not just run the search for me?
A web page has no access to your filesystem, so there is nothing here to search. The tool assembles the command and explains each part; your terminal runs it. Nothing you type leaves the page.
Will the command behave the same on macOS and Linux?
Usually, and the page is explicit where not. The building blocks were executed against BSD find, which macOS ships; Linux carries GNU findutils. Where the two differ — any-bits -perm, extended regex, -printf, -size rounding — you get labelled per-dialect answers, the GNU side cited to its manual.
What is the safe way to use -delete?
Run the same tests ending in -print first and read the list back — that dry-run line sits in the warning card whenever -delete or a removing -exec is selected. -delete asks no confirmation and uses no trash can.
Keyboard shortcuts
- ⌘/Ctrl + C
- Copy the command when nothing is selected and focus is in the tool.
- ⌘/Ctrl + Shift + C
- Copy the command even while text is selected.
- ? or ⌘/Ctrl + /
- Open the shortcut help overlay.
- t
- Cycle theme.
- Esc
- Close the overlay.