grep -B 3 'pattern' file.txt

Category: Text Processing

grep -B 3 'pattern' file.txt

Print 3 lines of context before each match

Shows the 3 lines before each match so you have context about what comes before the pattern.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.