Shell Basics · 8 min read · Beginner
Finding Files with find & xargs
Locate files by name, size, or modification time with find, and process results safely using -print0 and xargs -0.
What you'll learn
- Search directory trees by name (-name), type (-type f), and age (-mtime)
- Run commands cleanly on matched files using -exec or xargs
- Handle filenames containing spaces safely with -print0 | xargs -0
find searches entire directory trees with precision: find every .log file larger than 50 MB, or every .mdx lesson under src/. Combining find with wc -l or xargs makes bulk file inspection effortless.
Fill-in-the-Blank Exercise
Find Regular Markdown Files
Find all regular files (-type f) ending in .md inside docs/.
docs -type f - "*.md"Live Bash Lab
Bashfind_demo.sh
Expected OutputClick “Run Live” to compile with GNU Bash
/tmp/dp_find/a/one.txt /tmp/dp_find/b/two.txt
Check Your Understanding
Score: 0 / 1
1. Why should you quote "*.log" when running find /var/log -name "*.log"?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.