Articles
Published · July 9, 2026

How to Search Across Your Notes with grep and ripgrep

Your notes are plain text, so you already have a fast search tool sitting on your machine: the terminal. This guide covers grep and ripgrep basics, the flags worth knowing, and how to fix the most common search problems in a notes folder.

Quick answer

If your notes are plain text, you can search all of them from the terminal in seconds — no need to open a single file. Run grep -r "pattern" ./notes or rg "pattern" ./notes from the folder above your notes, and every match shows up at once: filename, line number, the surrounding text.

grep is preinstalled on almost every Unix-like system, which makes it the fastest option for a one-off search when you don't want to install anything. ripgrep (rg) does the same job with newer defaults. It searches recursively out of the box, skips hidden files and anything covered by a .gitignore, and is generally faster — the regex engine behind it uses finite automata and SIMD optimizations. Either tool turns a folder of notes into something searchable like a database, with no proprietary index required. That's one more reason a plain-text note-taking system keeps paying off over time.

Step-by-step

1. Open a terminal and move into your notes folder. cd ~/notes (or wherever your files live). Both tools search subfolders automatically from there — no need to run the command once per folder.

2. Try a basic search with grep.

grep -r "invoice" ./

-r makes it recursive. Add -i for case-insensitive matching, -n to show line numbers next to each hit, and -l if you just want filenames instead of the matching lines. Those four flags cover most everyday grep usage.

3. Try the same search with ripgrep.

rg "invoice"

No -r needed. Recursive search is the default, and ripgrep skips hidden files plus anything listed in a .gitignore automatically. Add --hidden if you specifically want dotfiles included.

4. Narrow the search when the folder is large. A few flags from the ripgrep guide are worth memorizing:

  • -g '*.md' — search only Markdown files, skip everything else in the folder
  • -F — treat the search term as literal text, not a regex pattern
  • -w — match whole words only, so "cat" doesn't also match "category"
  • -C 2 — show two lines of context above and below each match, useful for judging whether a hit is actually relevant

Once search points you to the right note, good heading structure gets you to the right section fast. See outlining long documents with headings if your notes tend to run long.

Common problems and fixes

"No matches" when you know the text is there. Check you're searching from the right directory. Check case, too — add -i to either tool if you're not sure how the text was capitalized. If your search term contains parentheses, brackets, or asterisks, those get read as regex syntax by default. Add -F (fixed-strings) in ripgrep, or quote the term carefully in grep, so it's treated as literal text.

Too many irrelevant results. Usually the search is running over more than just your notes — attachments, exports, or a backup folder sitting alongside them. Restrict by file type (-g '*.md' in ripgrep) or exclude a specific subfolder (--exclude-dir in grep) instead of searching everything.

Notes with code snippets muddy the results. Keep config snippets or code alongside your notes, and a plain search can surface partial matches inside code blocks that aren't what you're after. -w for whole-word matching and -C for context both help you tell prose hits from code hits at a glance. If you're the kind of person keeping dotfiles next to your notes, editing config files quickly on Mac and iOS is worth a look once you've found the file you need.

Doing this with Carets

Carets keeps every note as plain text and Markdown, organized into files, projects, and tags — so grep and ripgrep work on your notes exactly the way they work on any other text on disk. Nothing sits locked in a proprietary format or a database only the app can read.

Two things make this work well in practice. Your files stay plain text, portable and future-proof, so a terminal search finds every note — not just the ones an app happens to index. And Carets is native and fast, built for iOS and Mac rather than a web wrapper, so moving between writing in the app and searching from the terminal doesn't fight your file organization. Projects and tags in Carets map directly onto the folders and filenames a command-line search walks through.

To be fair: Carets doesn't have a built-in regex search bar today. Command-line search is the fast path for power users who want pattern matching across an entire notes folder, while in-app search covers everyday lookups inside the app itself.

Carets is available on iPhone, iPad, and Mac. Download it from the App Store to start keeping notes and code in files that stay searchable, wherever you search from.

Frequently Asked Questions

Is ripgrep better than grep for searching notes?

For a large notes folder, ripgrep is usually faster and needs fewer flags — it searches recursively and skips hidden or ignored files by default, where grep requires -r and explicit excludes. grep is still fine for a quick one-off search since it's preinstalled everywhere.

Can I search only Markdown files with ripgrep?

Yes. Use a glob to restrict the search — rg 'pattern' -g '*.md' — or rely on ripgrep's file-type filters if your notes use a recognized extension. That keeps results limited to your actual notes instead of config or asset files sitting in the same folder.

How do I search for an exact phrase instead of a regex pattern?

Add the -F (--fixed-strings) flag in ripgrep, or quote the phrase carefully in grep. This tells the tool to treat characters like parentheses or asterisks as literal text instead of regex syntax, which matters for notes that contain code snippets or special characters.

Will grep or ripgrep find text inside code blocks in my notes?

Yes. Both tools search plain text line by line regardless of Markdown formatting, so fenced code blocks, inline code, and prose all get searched the same way. That's one advantage of keeping notes as plain text instead of a proprietary format.

Conclusion

grep ships on nearly every machine and handles a quick search without any setup. ripgrep trades that ubiquity for speed and smarter defaults — recursive search, automatic filtering, full Unicode support — which pays off once a notes folder grows past a handful of files. Either way, the reason this works at all stays the same: once your notes are plain text, they're searchable with tools that already exist on your machine. No proprietary search index required.