Isso faz o que eu precisava:
/pattern1/ {
if (candidate) {
print "modify:", candidate
}
candidate=$0
next
}
/pattern2/ {
if (candidate) {
print candidate
candidate=0
}
}
{
if (candidate) {
print "modify:", candidate
candidate=0
}
print $0
}