http://www.perlmonks.org?node_id=979950


in reply to Getting lines in a file between two patterns

One option would be to use the range operator eg.
perl -e 'while (<>){print if (/^START/../^END/);}' input.txt
print "Good ",qw(night morning afternoon evening)[(localtime)[2]/6]," fellow monks."

Replies are listed 'Best First'.
Re^2: Getting lines in a file between two patterns
by frozenwithjoy (Priest) on Jul 05, 2012 at 05:21 UTC
    This will also print START/END, if this is not desired, try:
    perl -ne 'if (/START/../END/) {print unless /START/ or /END/}'