I think this sed command will do what you want:
sed '/bar/,+5d' input.txt
It deletes any line containing the text bar plus the next five lines.
Run as above to see the result. When you know that it works correctly, use the --in-place=.backup to actually make the change.
source share