# Delete text between patterns, excluding the lines containing these 2 patterns: sed '/PATTERN-1/,/PATTERN-2/{//!d}' input.txt # Delete text between patterns, including the lines containing these 2 patterns: sed '/PATTERN-1/,/PATTERN-2/d' input.txt # To delete all the lines after PATTERN, use this sed '/PATTERN/,$d' input.txt