I want to remove parts of a file starting from a match (including the first match) and until the second match (excluding the second match). My file looks like this, from another SO question:
3. line 3
4. line 4
## Screenshots ##
1. line 1
2. line 2
3. line 3
4. line 4
## Changelog ##
3. line 3
4. line 4
From the answers of the other question I have taken a sed
command that outputs from ## Screenshots ##
until 4. line 4
, just before ## Changelog ##
. However, I would like to remove that section from the file.
To clarify, I only know that the next section will start with ##
, it could be ## foobar ##
for all I know :)
I have tried to replace the print commands by delete commands like so
sed -e '/## Screensh/,/##/{/Scree/{d;n};/##/{q};d}' file
but that did not work because it stops output after the second match, ## Changelog ##
in this case (because of the quit command). I have also tried to use a regex character class to match anything but a #
character like sed -n '/## Screenshots ##[^#]*/p'
but that only prints ## Screenshots ##
.