Search text with line numbers and surrounding context
Build a paste-ready command, then review its compatibility and effects before running it.
rg -n -C <lines> --glob '<glob>' <pattern> <path>Complete required fields to copy the generated command.
read-onlyno known side effects Compatibility
Linux + macOS + WindowsVerified for Linux, macOS, Windows using bash, zsh, powershell syntax.
Operational knowledgereview due 2027-01-19
Requirementsrgrg must be installed and available on PATH.
Version supportrg Current supported releasesVerified for linux, macos, windows using bash, zsh, powershell syntax; consult compatibility notes for platform-specific differences.
Expected signalssrc/client.tsRepresentative successful output; values vary with the selected target and system state.
Known errorsrg: command not foundrg is missing or is not available on PATH.
Verifyrg -n -C {{lines}} --glob '{{glob}}' {{pattern}} {{path}}The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01rgCommandRuns the rg stage of this one-liner.
02-nOptionApplies the command-specific numeric, dry-run, or non-resolving mode.
03-COptionConfigures rg with the -C option.
04<lines>ParameterA value supplied in the Fill parameters section.
05--globOptionConfigures rg with the --glob option.
06'<glob>'ParameterA value supplied in the Fill parameters section.
07<pattern>ParameterA value supplied in the Fill parameters section.
08<path>ParameterA value supplied in the Fill parameters section.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
rg -n -C 2 --glob '*.ts' 'timeout' ./src
Example output
src/client.ts
41- const controller = new AbortController();
42- const timer = setTimeout(() => controller.abort(), 5000);
43: // request timeout
Illustrative output — exact values vary by system and data.
Official sources