Q:

Grep: show only 2nd line above

Let's say I have a text file with the content:
foo
bar
whatever

something I don't know
bar2
whatever

And, as an output from doing grep whatever myfile.txt (and/or sed and/or awk), I would like to have:
foo
something I don't know

I've tried using option -B 2 but that outputs both foo and bar.
Cannot do ... | grep -v bar as there are a lot of different records.

A:

So here's my solution as I couldn't find any way of doing it:  
As I was being returned with blocks of content, say:
foo
bar
whatever
--
foo2
bar2
whatever
--

and so on, I used grep's separator and got the very next line like so and then removed them:
grep -B2 whatever myfile.txt | grep -v whatever | grep -A 1 -E '\-\-' | grep -v  -E '\-\-'

And that just outputs:
foo
foo2

