じゃ、GNU grep で。

#!/bin/sh

grep --null-data -Po "(^|\n).* $2\(.*?\)(.|\n)*?{(.|\n)*?\n\K(.|\n)+?(?=\n?})" "$1"