How do I delete a block of _specific_ consecutive lines?
If the block of lines always looks like this (with ‘^’ and ‘$’ representing the beginning and end of line, respectively): ^able$ ^baker$ ^charlie$ ^delta$ and if there is never any deviation from this format (e.g., “able” *always* is followed by “baker”, etc.), this will work fine: sed ‘/^able$/,/^delta$/d’ files # most seds | sed ‘/^able$/,+3d’ files # HHsed, sedmod, gsed 3.02.80 | However, if the top line sometimes appears alone or is followed by other lines, if the block may have additional lines in the middle, or if a partial block could possibly occur somewhere in the file, a more explicit script is needed. The following scripts show how to delete blocks of specific consecutive lines. Only an exact match of the block is deleted, and partial matches of the block are left alone. # sed script to delete 2 consecutive lines: /^RE1\nRE2$/ $b /^RE1$/ { $!N /^RE1\nRE2$/d P;D } #—end of script— # sed script to delete 3 consecutive lines. (This script # fails under GNU sed earlier than