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
  • 71,145
  • 9
  • 121
  • 139
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
  • 161,154
  • 30
  • 262
  • 319