I am not really sure if this is already out there but I am having some trouble trying to express what I want to be done in a search field.
Say I had a file like the following
foo1
foo2
foo3
barbarbar
barbarbar
barbarbar
foo4
foo5
barbarbar
barbarbar
barbarbar
foo6
foo7
I want to only get the fields that have something other than "foo#" after a "foo#". I also want the "foo#" to be printed if it does have barbarbar after it and everthing that until the next "foo#". An example output would be below.
foo3
barbarbar
barbarbar
barbarbar
foo5
barbarbar
barbarbar
barbarbar