Delete all lines between two matching patterns including the matchings patterns
sed ‘/pattern1/,/pattern2/d’ input.txt
(apply delete command d
to whole match)
Delete all lines between two mathing patterns, excluding the matchings patterns
sed ‘/pattern1/,/pattern/{//!d}’ input.txt
(apply delete command d
only if line does not match the pattern)
Note: the d operator can be any other sed operator
sed '/pattern1/,/^pattern2/{//!s|.*|NEW_STUFF|)|}' CMakeLists.txt