-1

I want to print out a chunk of a text file with a specific start and end pattern.

For example file.txt has

Start X1
 <stuff_for_x1>
END

Start Y1
 <stuff_for_y1>
END

Start X2
 <stuff_for_x2>
END

and I want my output to be:

Start X1
 <stuff_for_x1>
END

Start X2
 <stuff_for_x2>
END

in which all the chunks begining with "Start X" and ending with "END" are printed.

I have no idea how to approach this. Your help will be very appreciated :)

Mark K
  • 1
  • 1

1 Answers1

0

Using to select all lines between one starting with (^) "Start X" and "END"

awk '/^Start X/,/^END/' file.txt 
johnsyweb
  • 136,902
  • 23
  • 188
  • 247