Skip to content
zero2vibecodelearn vibe coding
Level 3 · Search and pipes 5 min Reviewed by the author · Aug 4, 2026

Finding files: find

`find` walks through a folder and everything under it, listing the files whose names match a pattern.

Level 3 · 0 / 4 lessons0%

You know a file exists somewhere in the project. You do not know which folder.

ls will not help — it shows one folder at a time. You need something that walks down through everything.

find

find . -name "*.js"
./src/app.js
./src/utils.js

Read the command in three pieces:

  • find — the command
  • .where to start, in this case the current folder
  • -name "*.js"what to match

find starts at the place you named and goes down through every folder inside it, at every depth, printing the that match.

Quick check

In `find docs -name README.md`, what does docs mean?

The star

* in a pattern means “any characters, including none”:

PatternMatches
*.txtanything ending in .txt
app.*app.js, app.css, app.json
*test*any name with test somewhere in it

Tip

Quote the pattern: -name "*.js", not -name *.js. Without quotes, the tries to expand the star before find ever sees it, and you get results that depend on what happens to be sitting in your current folder. Quoting removes the surprise.

Quick check

Which pattern finds notes.txt, notes.md and notes.pdf?

What find does not do

find matches names. It does not look inside files at all. Searching for a word inside your files is a different command — grep — and that is the next lesson.

Keeping the two apart saves confusion later:

  • find — where is the file called something like this?
  • grep — which files contain this text?

Note

On a real machine find / searches the entire disk, which is slow and prints permission errors for system folders you are not allowed to read. Start from a project folder, not from the root.

Quick check

You need to know which file contains the phrase 'database timeout'. Which tool?

Try it

The project has files at two different depths.

  1. ls — notice you only see the top level: docs, src, todo.txt.
  2. find . -name "*.js" — both JavaScript files turn up, including the ones nested inside src.
  3. find . -name "*.txt" — three text files, from two different folders.

Compare step 1 with step 3. ls showed you one .txt file; find showed you all three.

Check your understanding

Answered 0/3
Mode:

What does the `.` mean in `find . -name "*.txt"`?

Why are the quotes around `"*.txt"` a good idea?

How is `find` different from `ls`?

Finish the task in the terminal and answer the questions to complete the lesson.

📝 My notes

Saved automatically in this browser · shows up on the Notes page.

Task

Find every .js file in the project, then every .txt file.

Tab complete · history · Ctrl+L clear · help commands

  • Not done: Search from the current folder with find
  • Not done: The nested .js file turns up
  • Not done: The .txt search finds the top-level file too

Lesson Q&A

What does the `.` mean in `find . -name "*.txt"`?

`.` is the current folder. find always searches downward from wherever you point it.

Why are the quotes around `"*.txt"` a good idea?

Without quotes the shell may expand the star itself and find never sees the pattern you meant.

How is `find` different from `ls`?

ls is one level. find is the whole subtree, however deep it goes.

In `find docs -name README.md`, what does docs mean?

The first argument is always the starting point. Everything under it gets searched.

Which pattern finds notes.txt, notes.md and notes.pdf?

notes.* keeps the name fixed and lets the extension be anything.

You need to know which file contains the phrase 'database timeout'. Which tool?

find only ever looks at names. Content is grep's job.

Move between lessons with · search with ⌘K