Finding without opening everything
Use `find` predicates to reduce a filesystem problem to a targeted list.
find . -type f -name '*.log'
20 min read, 30 min lab
beginner
`find` walks a tree and filters entries by type, name, time, size, permission, and more. It becomes powerful when the search is constrained and the output is handled safely.
A disk filled overnight. You need recent large log files under one application directory, not a random tour of the server.
Worked command
$ find /var/log -type f -name '*.log' -mtime -1$ find . -type f -size +10M -print$ find . -type f -name '*.txt' -print0
Do not run broad filesystem searches from `/` during an incident unless you understand the cost.
Constrain path first, then type, then name/time/size. Use null-delimited output for automation.
In `find /var/log -type f -name '*.log' -mtime -1`, what does `-type f` actually do to the result set?
Show the answer
Correct: A. Restricts matches to regular files, excluding directories and symlinks
`-type f` keeps only regular files, dropping directories, symlinks, and special files. The day window comes from `-mtime -1` and the name filter from `-name '*.log'`, not from `-type f`.
Practice checklist
- Create a throwaway tree with logs and notes.
- Find only `.log` files changed today.
- Repeat with `-print0` and explain why it exists.
Deliverable evidence
- A constrained find command.
- A note explaining why broad searches are risky.
shows: How `.`, `..`, and `~` resolve from the current directory into a single absolute location, with `pwd`/`realpath` confirming where you actually are and `find` filtering a tree down to evidence.
does not prove: It shows how path tokens resolve in principle; it does not prove your shell's current directory at any moment — only running `pwd` or `realpath` on the live machine proves that.
Commit these to memory, then drill them until recall is automatic.
cue Feed find's matches to another tool safely when filenames may contain spaces or newlines.
show recall target
-print0