Question : grep show lines above and below
Answered by : important-iguana-rxht8hjyf2vv
grep -C 3 foo README.txt
Source : https://stackoverflow.com/questions/9081/grep-a-file-but-show-several-surrounding-lines | Last Update : Sun, 05 Jul 20
Question : lines before and after grep
Answered by : dwij-sheth
You can use the -B and -A to print lines before and after the match.
grep -i -B 10 'error' data
Will print the 10 lines before the match, including the matching line itself.
Source : | Last Update : Wed, 28 Apr 21
Question : grep lines before and after
Answered by : taha-zouhair
# display 3 lines before and after matchline
rg -C 3 "keyword"
Source : | Last Update : Tue, 23 Aug 22