find command (Linux / bash / sh / zsh)
What it does
Walk directory trees and select entries using tests and actions. When people search for the find command linux examples, they usually want find's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.
Walk directory trees and select entries using tests and actions.
Syntax
find [PATH...] [EXPRESSION]
Common options
| Flag / option | Meaning |
|---|---|
| -name PATTERN | Match a case-sensitive file name. |
| -type TYPE | Restrict matches to files, directories, or another type. |
| -mtime N | Match by modification age in days. |
| -exec CMD {} + | Run a command with batches of matches. |
Practical examples
Find logs
find /var/log -type f -name '*.log'
Locates regular log files below /var/log.
Large files
find . -type f -size +100M
Finds files larger than 100 MiB.
Delete stale temp files
find /tmp -type f -mtime +7 -delete
Deletes files older than seven days after selection.
Linux ↔ Windows equivalent
Closest match: Get-ChildItem (Windows / PowerShell). Enumerate items and child items in filesystem, registry, and other providers.
Common mistakes
- Failing to quote wildcard patterns, allowing the shell to expand them early.
- Putting `-delete` before restrictive tests, which can remove too much.
Related commands
- xargsBuild and run command invocations from standard input.
- whichLocate the executable selected from the current PATH.
- grepSearch text for lines matching a pattern.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- cdDisplay or change the current directory in Command Prompt.
FAQ
What does find do in Linux?
Walk directory trees and select entries using tests and actions.
How do I use find from the terminal?
Start with `find [PATH...] [EXPRESSION]`, then choose only the options needed for the task.
What is a practical find example?
Try `find /var/log -type f -name '*.log'` — Locates regular log files below /var/log.
Can I use find in a shell script?
Yes. find works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.