sed -n '/{\|}/ !{H; b}; /{/ {h; b open}; :open {/}/ b close; n; H; b open}; :close {g; /programmer/ p}' File
解释:
$ sed -n '#suppress printing of all input
> /{\|}/ !{H; b} # if no curly brackets on the line, append it to hold space and finish
> /{/ {h; b open} # if an opening { is found, copy the line to hold space and branch to label :open
> :open
> /}/ b close # if a } is matched, branch to label close
> n; H; b open # else read a new line, append it to hold space and go back to :open
> :close
> g # put all hold space to pattern space
> /programmer/ p # if _programmer_ matches, print the pattern space' File