June 14, 2026 · by Meegrow Labs

grep -r: Search Every File in a Folder at Once

You remember writing it down. One word, one note, somewhere in a folder full of files. But which file? Opening each one by hand would eat your whole evening, and you still might miss it.

Here is the good news: your computer can search every file for you in a single command.

To search every file in a folder for a word at once, use grep -r — the -r flag tells grep to look recursively through all files in the folder instead of just one, so you find your text instantly.

What does grep -r actually do?

On its own, grep looks inside a single file and prints the lines that contain a word you give it. That is useful, but limited — you have to point it at one file at a time.

Add the small -r flag and everything changes. The r stands for recursive, which is a fancy way of saying “go through every file in this folder, and every folder inside it too.” One pass, every file, no clicking.

Think of it like asking a friend to flip through every notebook on your shelf and shout out every page that mentions your word. That is exactly what grep -r does, in a fraction of a second.

How do I write the full command?

The command has three simple parts. You type them in this order:

grep -r TODO .

Here is what each part means:

  • grep — the tool that finds your word inside text.
  • -r — the flag that makes it cover every file, not just one.
  • . — a single dot, which means “this folder, right here.”

So grep -r TODO . reads as: “Search for the word TODO across every file in this folder.” Swap TODO for any word you are hunting — a name, a phone number, a half-remembered phrase.

Why is searching everywhere so useful?

Imagine all your chat exports sitting in one folder. You want every message that mentions “refund.” Instead of opening each chat file one by one, you run a single command and read every match together.

That is the real power here. One command checks every file, instantly, and lists exactly where your word appears. You stop hunting file by file and start finding answers in seconds.

This habit pays off again and again — in code, in notes, in logs, in any pile of text files. It is one of those small skills that quietly makes you faster at everything. If you are starting from scratch, you can pick up these basics step by step in the free Zero to AI Hero course.

How do I try grep -r right now?

The best way to learn this is to run it. Open a terminal, move into any folder with a few text files, and type:

grep -r TODO .

It lists every line, in every file, that contains TODO. If you have never typed a search like this before, it feels a little magical the first time. If your terminal still feels new, our walkthrough on how to use the terminal gets you comfortable fast.

Once you can find text across a whole folder, the natural next step is chaining commands together with pipes — sending the output of one command straight into another to do even more in one line.

Key takeaways

  • grep -r searches every file in a folder for a word, all at once.
  • Plain grep checks one file; the -r flag makes it recursive across all files and subfolders.
  • The full command is grep -r <word> . — word to find, then a dot for “this folder.”
  • It is perfect for finding text across chats, notes, code, or logs without opening each file.
  • Try it now: grep -r TODO . in any folder, then explore more in the free course.

🚀 Take the full free course: Zero to AI Hero — learn to build with AI from scratch. New lessons daily, in Hindi & English.

Meegrow Labs

We help India go from zero to AI hero — learn to use & build with AI from scratch, in Hindi & English. Start the free course →

Want to actually learn this?

151 free 2-minute lessons — from "what's a file?" to building with AI.

▶ Start the free course