perl -ne 'print if $,;$, = /PATTERN/' input