foam grep
Search note content by pattern.
foam grep <pattern> [options]Searches the text content of all notes in the workspace. The pattern is matched case-insensitively as a regular expression. Unlike foam search, this command searches the full text of each note rather than indexed metadata.
Options
Section titled “Options”| Option | Description |
|---|---|
--context <n> | Show n lines of surrounding context around each match |
--no-line-number | Omit line numbers from output |
--limit <n> | Max number of matching files to return (default: 20) |
--workspace <dir> | Workspace root (default: FOAM_WORKSPACE env var, then current directory) |
--format <fmt> | Output format: text (default) or json |
Examples
Section titled “Examples”Search for a word across all notes:
foam grep "quantum"# physics/quantum-mechanics.md:3: Quantum mechanics describes...# research/reading-list.md:12: See also quantum entanglementSearch with context lines:
foam grep "TODO" --context 2Limit results:
foam grep "meeting" --limit 5Use in a script (JSON output):
foam grep "action item" --format jsonLINKS TO THIS PAGE
Foam CLI
Published with Foam