Linux for Developers
/Intermediate
find
Definition
A highly powerful command-line utility that searches for files and directories in a directory hierarchy based on user-evaluated expressions (name, size, modification date, permissions).
Explain Like I'm New
The ultimate search engine for your hard drive. You can say 'Find me all files bigger than 50MB that were modified yesterday and end in .log', and it will find them.
Real World Example
A server runs out of space. The admin types `find /var/log -type f -size +1G`. It searches the log directory and instantly finds exactly which log files are massive and clogging the drive.
Common Use Cases
- •Complex file searches
- •Automated cleanup scripts
Crucial Command Flags
| Flag / Option | Description |
|---|---|
| -name | Search by exact file name. |
| -type | Search by file type (f for file, d for directory). |
| -mtime | Search by modification time (e.g., -mtime -7 for last 7 days). |
| -exec | Execute a command on every file found. |
Interview Questions
basic
- How do you search for a file named exactly 'config.json' in the current directory?
intermediate
- What does the `-exec` flag do when attached to a `find` command?