Finding Files by Name (find)
Concept & Overview
Imagine misplacing an important text file somewhere in your user folder and having to search through dozens of nested directories one-by-one. In Linux, we bypass manual digging by using the find utility as a lightning-fast system-wide search engine.
- The find command searches through directory trees based on name, size, type, or date.
- The syntax is find . E.g., find . -name "*.txt" searches the current directory and all subfolders for files ending in .txt.
Why this matters: If you run find . "*.log" without -name, you will get the error: find: paths must precede expression: '*.log'. The -name flag is required to specify that the subsequent pattern should be matched against the filenames.
.log extension by running find . -name "*.log".Command Syntax Reference
| Command / Syntax | Description |
|---|---|
find . -name "*.log" | Find all files ending in .log in current folder and subfolders |
Verification Objectives
These conditions will be automatically verified when you run commands inside the interactive terminal simulator:
- ○Run the "find" command with -name option
Ready to complete Quest 82?
Test your skills live in the browser terminal with an emulated Linux filesystem, real-time command evaluation, and instant step-by-step hints.