You can do this with a loop in GNU sed
:
sed -n '/trigger/{p; :loop n; p; /trigger/q; b loop}'
Explanation:
- When you see the first
/trigger/
, start a block of commands p
— print the line:loop
— set a label namedloop
n
— get the next linep
— print the line/trigger/q
— if the line matches/trigger/
then exitsed
b
— jump toloop