I found a similar question here, but it is not exactly what I want.
Let's suppose I have a text file like this:
[...]
age: 10
country: United States
city: New York
name: John
age: 27
country: Canada
city: Toronto
name: Robert
age: 32
country: Mexico
city: Guadalajara
name: Pedro
[...]
I want to match the line starting with "name: Robert" and print the 3 previous lines along with the matched result, getting only these lines:
age: 27
country: Canada
city: Toronto
name: Robert
How can I do this in the terminal?
name: J.K. Rowling
?