perl -ne '$in = 1 if / dev$/; $last_lines = 1 if / manage$/; $stop = 1 if $last_lines && ! / manage$/; print if $in && ! $stop; ' < file