. for current directory, an absolute path like /var/log, or multiple space-separated paths.find walks a directory tree and applies predicates (tests) and actions to each file it visits. Predicates are AND-ed by default. The default action, if none is given, is -print.
find [path] [predicates] [actions]
Most predicates take an argument right after the flag. Glob patterns are matched against just the file name by default (use -path for the full path).
| -name PATTERN | Match base name (case-sensitive glob, e.g. "*.log"). Quote to prevent shell expansion. |
| -iname PATTERN | Case-insensitive name match. |
| -path PATTERN | Match full path (glob). |
| -regex PATTERN | Regex match on full path. |
| -type t | File type: f=file, d=dir, l=symlink, b/c=block/char dev, p=pipe, s=socket. |
Numeric predicates use a sign prefix:
| -mtime 7 | Exactly 7 days (≥7 and <8 24-hour periods ago). |
| -mtime -7 | Less than 7 days ago (newer than). |
| -mtime +7 | More than 7 days ago (older than). |
| -size +100M | Larger than 100 MB. Suffixes: c=bytes, k=KiB, M=MiB, G=GiB. |
| -size -1k | Smaller than 1 KiB. |
| Default. Print each matching path. | |
| -print0 | Print null-terminated paths. Pair with xargs -0 for safe handling of filenames with spaces. |
| -delete | ⚠ Remove each match. Always test first by replacing -delete with -print. |
| -exec CMD {} \; | Run CMD on each match. The {} is replaced by the file path; \; ends the command. One invocation per file. |
| -exec CMD {} + | Like above but batches as many files as fit into one invocation. Much faster. |
| -execdir CMD {} \; | Like -exec but runs from the directory containing the file. Safer than -exec. |
| -ok CMD {} \; | Like -exec but prompts before each. |
| Find big files | find / -type f -size +100M 2>/dev/null |
| Recent edits | find . -type f -mtime -1 |
| Empty directories | find . -type d -empty |
| By name, delete | find . -name "*.tmp" -delete |
| Find & grep | find . -name "*.py" -exec grep -l "TODO" {} + |
| Stop at depth 2 | find . -maxdepth 2 -name "README*" |
| Owned by user | find /home -user alice -type f |
| Setuid binaries | find / -perm -4000 -type f 2>/dev/null |
• For simple tests, order usually affects performance more than results — put fast tests first: -type f before -name, -name before -exec. But with actions such as -delete, -exec, -prune, or expressions using -o, order can change what happens. Test with -print first.
• To combine with OR or negate, edit the command manually: \( -name "*.log" -o -name "*.txt" \), ! -name ".*".
• Pipe error output to /dev/null when scanning / to hide permission warnings: find / ... 2>/dev/null.
• For files with spaces in names, always use -print0 | xargs -0 instead of | xargs.
This is an educational tool. The commands it builds are real — they will do exactly what you tell them to. Some flags are destructive (deletion, overwriting, forced operations) and even non-destructive options can cause data loss or system trouble in the wrong circumstances.
• Always review the generated command before running it.
• Test on disposable files and directories first.
• If you do not understand what a flag does, look it up in the official manual page (man command).
The author of these pages is not responsible for any damage, data loss, or other consequences resulting from commands generated, copied, or run from this site. Use at your own risk.
⚠ These tools build real shell commands. Review every command before running it. The author is not responsible for any damage, data loss, or other consequences resulting from commands generated, copied, or run from this site. Use at your own risk.
Send comments and bug reports to chris@chrisspackman.com.
Version 0.2.0 — Last updated: 2026-05-26
This page is Copyright © 2026
Chris Spackman <chris@chrisspackman.com>.
This web site developed entirely on GNU/Linux with Free / Open Source Software.
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.