The same options apply to both grep
and ripgrep
(rg
).
Show the Lines Before the Matching Lines
rg -B 3 "keyword" filename
Show the Lines After the Matching Lines
rg -A 3 "keyword" filename
Show the Lines Around the Matching Lines
rg -C 3 "keyword" filename