Grep multiple search terms with context

I have a file that is a sort library in the format:

##def title1

content1
stuff1

content2
stuff2

##enddef
##def title2

etc..

I want to grep def and content and pull some trailing context from content

so the result would look something like:

##def title1
content2
stuff2
##def title2
content2
 stuff2
etc..

something like:

$ grep '##def|Content2 -A 1' ./file

where the -A 1 only applies to the second search term.

thoughts?

thanks.

Hi, try this:

awk '/##def/{print; if( getline && getline ) print }' RS= infile
awk '/##def/ && c=3; --c==0' RS= infile