Linux grep and find
Find files by name, age, and size; search inside them fast.
- linux find
- grep recursive
- find mtime
- xargs
- search files
Linux grep and find
Find files by name, age, and size; search inside them fast.
Commands
| Command | What it does |
|---|---|
find . -name pattern | Files by glob |
find . -mtime -7 -type f | Modified in last 7 days |
find . -size +100M | Larger than 100 MB |
grep -rn TODO src/ | Recursive content search |
grep -rl secret, exclude git | File names only, skip VCS |
Example
find . -type f -name '*.log' -mtime +30 -print
grep -rn 'FIXME' src/ | head
FAQ
Is find -delete safe?
Always run with -print first, then swap to -delete - there is no trash recovery.
Spaces in filenames break xargs?
Use -print0 with xargs -0, or -exec with plus for batching.
FAQ
Is find -delete safe?
Always run with -print first, then swap to -delete - there is no trash recovery.
Spaces in filenames break xargs?
Use -print0 with xargs -0, or -exec with plus for batching.
Linux
Linux Files and Directories
Navigate, create, move, and inspect files with core commands.
Linux Permissions
Read ls output, chmod, chown, and sudo without breaking access.
Linux Text Processing
cat, head, cut, sort, uniq, and awk for daily data shaping.
Linux Processes
See what runs, what eats CPU, and how to stop it cleanly.