~/tutorials/007-finding-things.md
007: Finding things
Three tools, three different questions. tree draws the whole map. find searches names. grep searches inside files, and it only works at the end of a pipe.
The map
tree | head -8
One screen, the whole shape. Six directories at the time of writing, and tree | grep / | wc -l is how you stop having to trust me.
Names
find tutorials
find flag
find takes one term and matches it against every name, quietly, without caring about case: find Flag finds the same things. It answers with paths, which lesson six made cheap.
Names that begin with a dot are a different matter. ls does not show them, and neither does find. ls -a shows the ones where you stand, because a file nobody can list is a file nobody finds.
Lines
ls ~/news | grep -i router
cat ~/news/2026-09-10-mikrotik-routeros-privilege-escalation.md | grep -i router | wc -l
grep keeps the lines that match. With -i it ignores case, which matters more than it sounds: the same idea written Router, router and ROUTER is one idea. The two commands above disagree on purpose. One name matched. Inside the file, seven lines did. <!-- claim: 1 = ls ~/news | grep -i router | wc -l --> <!-- claim: 7 = grep -i router ~/news/2026-09-10-mikrotik-routeros-privilege-escalation.md | wc -l --> find answers where something is called something. grep answers where something is said. Most questions are one of those two.
Nothing
find zzzz
A find with no matches says so in one line. A grep with no matches says nothing at all, which is lesson one's first lie waiting to happen: printed nothing is not the same as nothing.
Try it
Each of these has one answer, and the shell gives it to you. Check yourself.
- How many directories are there? One
tree, one grep, one count. - How many markdown files exist in the whole tree?
findaccepts any part of a name. - Which news files say
cvesomewhere inside, not just in the name?cat, a pipe, and reading what comes back. - Ask
findfor something that does not exist, then askgrepthe same way. Read both answers.
Counts here go stale as the tree grows, this lesson included. That is not a bug in the lesson. Run the command and you have the current truth.