When to use find
Use find to select files by metadata within a directory tree. Choose a narrow starting path first and inspect the matches before adding actions that modify or delete files.
Syntax
find [START_PATH] [CONDITIONS]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Find project logs
find ./logs -type f -name '*.log'The quoted wildcard is evaluated by find, not expanded prematurely by the shell.
Find recently modified files
find ./src -type f -mtime -2Matches are regular files whose modification age is less than two 24-hour periods.
Show files larger than 100 MiB
find ./data -type f -size +100MThe size filter selects files larger than one hundred mebibytes; it does not sum directory sizes.
Notes and limitations
- Start at the directory you need to avoid scanning the entire server unnecessarily.
- Inspect the matches before adding -delete or -exec: these actions can modify the matching files.
Common questions and troubleshooting
How do I search names without matching case?
Use -iname instead of -name where supported. Keep the wildcard quoted so the shell does not replace it with local filenames.
Why do some directories produce Permission denied?
The account cannot traverse or read those directories. Search only the intended accessible tree; suppressing errors does not make the results complete.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man find.