[awk] Print lines between two patterns

Created on November 30, 2026

Use an awk range pattern to select lines from a starting match through an ending match.

printf 'before\nSTART\none\ntwo\nEND\nafter\n' |
  awk '/START/,/END/ { print }'
START
one
two
END

The range /START/,/END/ includes both matching boundary lines.

awk Shell command