I am trying to get all lines between first occurrence of pattern1 and last occurrence of pattern 2 both the patterns are regex
Example code
TEXT
TEXT
[SUN_START]
[SUN_END]
[MON_START]
TEXT
[MON_END]
[TUE_START]
[TUE_END]
[WED_START]
TEXT
[WED_END]
TEXT
TEXT
Output that I am expecting is
[SUN_START]
[SUN_END]
[MON_START]
TEXT
[MON_END]
[TUE_START]
[TUE_END]
[WED_START]
TEXT
[WED_END]
Pattern is XXX_START and XXX_END
What I am got so far is
cat /u01/app/oracle/admin/LNOPP1P/config/dbbackup_LNOPP1P.config | sed -n -e '/[[A-Z][A-Z][A-Z]_START]/,/[[A-Z][A-Z][A-Z]_END]/p'
But this does not keep the line breaks and displays everything together like this
[SUN_START]
[SUN_END]
[MON_START]
TEXT
[MON_END]
[TUE_START]
[TUE_END]
[WED_START]
TEXT
[WED_END]
I also want to make sure that it only matches the line starts with [[A-Z]_START] and same for END