find Command Generator — Build & Decode Linux find Commands
The find syntax is famously unmemorable. Pick what you're searching for and
get the exact command — with every predicate explained. Or paste a find
command to decode it. Runs entirely in your browser, no signup.
Your command
—
Or: decode a find command
Paste any find command — every predicate gets explained.
How find reads, left to right
find takes a starting path, then a chain of tests
(type, name, size, time…) that each file must pass, and finally an action
(-print, -delete, -exec). So find . -type f -name
'*.log' -delete reads as "starting here, for every regular file whose name matches
*.log, delete it." Tests with no action default to printing the path.
The two that trip everyone up
- Always quote name patterns.
-name '*.log'with quotes letsfinddo the matching. Without quotes the shell expands*.logfirst and you get confusing errors. -mtimesigns are backwards from intuition.-mtime -7means "modified within the last 7 days";-mtime +30means "older than 30 days". No sign means "exactly N days ago".
Gotchas worth knowing
-exec … {} \;runs once per file;{} +batches them. The{}is replaced by each match and\;ends the command. Using+instead of\;passes many files at once — far faster for big trees.-deletehas no undo. Always run the same find without-deletefirst to see exactly what it would remove.-maxdepthmust come before other tests on some systems, or you get a warning. Put it right after the path to be safe.- Size units matter.
-size +100Mis megabytes; bare numbers are 512-byte blocks, which surprises people. Usecfor exact bytes.
Frequently asked questions
How do I find files by name in Linux?
find . -name '*.txt' searches the current directory recursively for files ending in
.txt. Add -type f to skip directories, or -iname to ignore
case.
How do I find and delete files older than 30 days?
find /path -type f -mtime +30 -delete. Run it without -delete first to
preview what matches before anything is removed.
How do I find large files?
find . -type f -size +100M finds files over 100 MB. Pipe to sort or add
-exec ls -lh {} + to see their sizes.
What does {} \; mean in find -exec?
{} is replaced by each matching path, and \; tells find the command has
ended. Swap \; for + to run the command once on a batch of files.
Building archives or setting permissions next? See the tar generator and chmod calculator, or all tools on the home page.