find - Search the Live Tree
find - the workhorse
Scenario: "There's a rogue 4GB file somewhere under /var eating the disk - find it." This is a real ticket, and find is how you close it in seconds.
find walks a directory tree in real time and matches files against tests.
find <where> <test>
find /var -name '*.log'
| Command | Finds |
|---|---|
find . -name report.txt | Exact name under current dir |
find /etc -iname '*.conf' | Case-insensitive, wildcard |
find /home -type d | Directories only (f = files) |
find . -empty | Empty files/dirs |
$ find /etc -name '*.conf' | head -3
/etc/ssh/ssh_config
/etc/logrotate.conf
/etc/ld.so.conf
Tip: Quote your wildcards:find . -name '.log'(with quotes). Unquoted, the shell expands.logbefore find ever sees it, and you get confusing errors.