$ printf "Line1\nLine2\nLine3\n\nXYZ: Blah\n" | perl -0777pe "s|\nXYZ.+\n||" Line1 Line2 Line3