Mission 11 of 30
Find Command Mastery
Locate a missing file and prove the match before acting on it.
Locate files by name, type, size, time, permissions, and then act carefully on the results.
Practice inside
~/linux-practice. Check your setup before you begin.
Prerequisite: Awk Fundamentals
.
What you’ll practice
- Search by name/type/size/time
- Use -exec
- Understand safer delete workflow
The mental model
- find starts at a folder and walks downward.
- Print results first before deleting.
- -exec runs another command on each match.
Try it in your terminal
Create search lab
Safe in practice folderCreates harmless test files.
Run from ~/linux-practice
cd ~/linux-practice
mkdir -p find-lab/subdir/nested
touch find-lab/file1.txt find-lab/file2.pdf find-lab/old.log find-lab/subdir/test.txt Find files
Safe in practice folderSearches by name and type.
Run from ~/linux-practice
find find-lab -name '*.txt'
find find-lab -type f
find find-lab -type d
find find-lab -empty Act on results
Safe in practice folderLists matching files and prints logs before any deletion.
Run from ~/linux-practice
find find-lab -name '*.txt' -exec ls -lh {} \;
find find-lab -name '*.log' -print Delete only after printing
CautionDeletes only the practice .log file after you have confirmed the match.
Run from ~/linux-practice
find find-lab -name '*.log' -delete Put it into practice
- Find all .txt files inside find-lab.
- Use -exec wc -l on matching files.
Check your result
Every match is printed before any action is taken.
Common mistakes
- You run `find / -name '*.tmp' -delete` and watch it chew through your entire filesystem. Two problems: you started from `/` instead of your project folder, and you didn't check what matched before deleting. Run the command with `-print` first. Read the list. Then decide.
- You type `find . -delete` thinking it deletes files in the current folder. It actually deletes everything the find command traverses — including subdirectories. Be specific: `find . -name '*.log' -delete` targets only .log files. Always name what you're looking for.
Check your understanding
Explain these in your own words. If you’re unsure, revisit the examples before moving on.
- Which option searches by file type?
- What should you do before -delete?
Your practice, your pace
Loading saved progress…