Skip to main content
deleted 4 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 162

Using awk:

awk '/^STAC$/,/$ /' input

This will print all lines between STAC and anything (including the matching lines)


Or using a grep that supports the -z option (BSD grep does not):

Treat input and output data as sequences of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline.

grep -z 'STAC' input

Using awk:

awk '/^STAC$/,/$ /' input

This will print all lines between STAC and anything (including the matching lines)

Using awk:

awk '/^STAC$/,/$ /' input

This will print all lines between STAC and anything (including the matching lines)


Or using a grep that supports the -z option (BSD grep does not):

Treat input and output data as sequences of lines, each terminated by a zero byte (the ASCII NUL character) instead of a newline.

grep -z 'STAC' input
deleted 4 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 162

Using GNU awk:

awk '/^STAC$/,/$^$ /' input

This will print all lines between STAC and anything (including the matching lines)

Using GNU awk:

awk '/^STAC$/,/$^/' input

This will print all lines between STAC and anything (including the matching lines)

Using awk:

awk '/^STAC$/,/$ /' input

This will print all lines between STAC and anything (including the matching lines)

deleted 4 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 162

Using GNU awk:

awk '/^STAC$/,/\[^\]*$^/' input

This will print all lines between STAC and anything (including the matching lines)

Using GNU awk:

awk '/^STAC$/,/\[^\]*/' input

This will print all lines between STAC and anything (including the matching lines)

Using GNU awk:

awk '/^STAC$/,/$^/' input

This will print all lines between STAC and anything (including the matching lines)

added 5 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 162
Loading
Won't work in any other awk
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k
Loading
Source Link
jesse_b
  • 41.6k
  • 14
  • 108
  • 162
Loading