I have a problem where I have a large amount of files that I need to scan and return a line and its following line, but only when the following line begins with a string.
String one - line one must begin with 'Bill'
String two - line two must begin with 'Jones'.
If these two criteria are matched, it returns the two lines. Repeat for the whole file.
ie. original file:
Edith Blue
Edith Green
Edith Red
Bill Blue
Jones Red
Edith Green
Bill Green
Edith Red
Jones Green
Bill Blue
I'd want it to return only:
Bill Blue
Jones Red
Any ideas? No idea where to begin with this, I only have basic scripting skills with sed/awk etc... At the moment I am using this to get the filename and its following line, but it is giving me too much useless information that I have to strip off with other sed commands.
grep -A 1 "^Bill" * > test.txt
I guess there's a far more elegant way of getting only the lines I need. Any help would be lovely!