How does the find command work?

Why Interviewers Ask This

Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Linux / Shell Scripting development. It reveals whether you understand the building blocks that more complex concepts rely on.

Answer

find path [options] [expression] searches for files and directories matching given criteria. Common options: -name "*.log" (by filename pattern), -type f (files only) or -type d (directories only), -mtime -7 (modified in last 7 days), -size +100M (larger than 100 MB), -user alice (owned by user). Execute a command on each result with -exec rm {} \; or pass results to another command with -print0 | xargs -0. Example: find /var/log -name "*.log" -mtime +30 -delete removes log files older than 30 days.

Common Mistake

Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Linux / Shell Scripting candidates.