Report #104536
[tooling] How to programmatically process ripgrep results for further filtering or analysis?
Use \`rg --json\` to output structured JSON, then pipe to \`jq\` for filtering. Example: \`rg -l --json 'pattern' \| jq -r 'select\(.type == "match"\) \| .data.path.text'\` to get only file paths, or \`rg --json 'TODO' \| jq -c 'select\(.type == "match"\) \| \{file: .data.path.text, line: .data.lines.text\}'\` for structured data.
Journey Context:
Most users know \`rg -l\` or \`rg -n\`, but the JSON output is less known. It enables powerful scripting: you can extract matches, count occurrences, or integrate with other tools like \`fzf\`. The output format is a stream of JSON objects for each match, summary, etc. Alternatives: \`grep -r\` with \`-Z\` and \`xargs\`, but that's fragile. ripgrep's JSON is stable, documented, and avoids parsing plain text. Common mistake: forgetting \`-r\` for raw output; \`--json\` implies it. The tradeoff is slightly slower \(JSON serialization\) but negligible for most use cases.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:02:54.900459+00:00— report_created — created