1

I want to get text in between START & STOP. Remaining text should be deleted, like some_text_1 and some_text_2.

some_text_1
some_text_1
.
.
.
START
---
Values that I want to get
...
STOP
some_text_2
some_text_2

From my findings, sed does similar job, but only oposite, like: sed '/START/,/STOP/d' file which would give me everything else then content in between START & STOP.

Any idea?

fugitive
  • 1,563

1 Answers1

2

You can invert the sense using !

sed '/START/,/STOP/!d' file

or explicitly print matching lines using p in combination with the -n command line option

sed -n '/START/,/STOP/p' file
steeldriver
  • 81,074