I am trying to find a string occurring before my grep result.
before = text1234
foo = 1234
bar = 1234
var = words
before = text2345
foo = 2345
bar = 2345
etc = 2345
var = words
I am using grep grep -n var * to get the results of var. But I am trying to find the first occurrence of before before the grepped line.
I have tried using the grep -B 10 option, but since the lines are variable it is not exactly what I want.
The ideal result would return:
before = text1234
before = text2345
I think there is some sed/awk magic that would help, but I am not sure what it could be based on my google-fu