I have several text files with this format:
name: john address: bay area phone: 6505561234 image: /work/myimage.png name: stark dob: 5AD shirt color: red physical address: Westros phone model: S2 email id: firstname.lastname@example.org phone model: S2 name: tara dob: 1ad shirt color: red physical address: Westros email id: email@example.com
There can be multiple 'person's or 'contact's. Let's say I want to find all persons with 'S2' phone model.
I can do a 'grep' - that would just return this:
phone model: S2 phone model: S2
I can use the before/after context on grep - but that's just a fixed number of lines before/after that get printed out. With a 'previous' context of 3, I might get something like this:
shirt color: red physical address: Westros phone model: S2 --- name: tara dob: 1ad phone model: S2
But that's not what I want. I want the entire 'record' to show up. Any clues on how to go about doing this with standard unix commands?