~/grep(1) en

GREP(1)General Commands ManualGREP(1)

NAME

grep - search the notes

SYNOPSIS

grep [-icnlqrv] pattern [file ...]

DESCRIPTION

Searches notes for a pattern and prints the lines that match, each behind a link to the note it came from and with the match itself marked. A note is named by the path grep reached it through, so a match in a subdirectory is named with the subdirectory. Flags can be written together: grep -rin beans is grep -r -i -n beans.

Nothing matched prints nothing at all, which is both what grep does and how you know it looked.

A directory needs -r, exactly as it does everywhere else — grep beans work/ is an error, grep -r beans work/ is a search. What grep cannot read it says so about and then carries on with whatever else you gave it.

With no file at all, real grep reads standard input: that is why grep beans on its own looks like it has hung in a real terminal — it is waiting for you to type, and Ctrl-D ends it. There is no standard input here, so this says as much instead of pretending. grep -r beans searches from where you are standing downwards, which is what GNU grep does with -r and no path.

Two things worth knowing:

  • the pattern is a JavaScript regular expression rather than the POSIX one real grep takes. Anything you would reasonably type behaves the same.
  • a note’s text is the note as this site renders it, so the frontmatter — title, tags, summary — is not part of what is searched, and a line is a paragraph, which is the shape the shell is handed. -n and -c therefore count paragraphs, not the lines of the file in your vault.

apropos is the same idea pointed at the manual instead.

OPTIONS

-i
ignore case
-n
print the number of each matching line
-c
print how many lines matched in each note, not the lines
-l
print only the notes that matched
-v
select the lines that do not match
-q
print nothing at all; the answer is the exit status, which is how an if asks whether a note holds something
-r, -R
search directories. Both spellings mean the same here: there are no symlinks to follow differently.

EXAMPLES

grep -r vegan

grep -rin nixos ~/writing

grep flake work/this-site.md

SEE ALSO

rg(1), cat(1), ls(1), apropos(1)

tilenkoren.com2026GREP(1)