jamesatha
jamesatha

Reputation: 7600

Using Grep to get the line that had the match and the following line

I have a file of records. The first line has the name and the following line has the data associated with that person. I want to grep for a persons name and get the line with the name and the line that follows.

Upvotes: 1

Views: 150

Answers (2)

Tim Lamballais
Tim Lamballais

Reputation: 1054

grep -C1 regex filename

Upvotes: 0

Riccardo Galli
Riccardo Galli

Reputation: 12925

grep -A 1 "person name" fileName

Upvotes: 4

Related Questions