1

I am trying to extract data between strings using sed.

sed -n '/SUBCASE 1/,/SUBCASE 2/p' file.txt

SUBCASE 1 is repeated in several lines of the document as shown below.

SUBCASE 1
.

.
.
.

SUBCASE 2
.
.

.
.
.

SUBCASE 1

.
...
.

SUBCASE 3

How do I extract the data between SUBCASE 1 and SUBCASE 2?

Inian
  • 80,270
  • 14
  • 142
  • 161
Prasad
  • 19
  • 1

1 Answers1

0

Try this:

sed -e 's/SUBCASE 1\(.*\)SUBCASE 2/\1/'

or

sed -n '/^SUBCASE 1$/,/^SUBCASE 2$/p' file.txt
Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331