in reply to Re: print data between two regular expressions
in thread print data between two regular expressions


For the case where it isn't known that [cow] follows [moo] you could also use the ... range operator to make the solution more general. The following prints the range from [moo] to the next line starting with [:
perl -ne'print if /^\[moo\]/ ... /^\[/ and !/^\[/' log.txt

The 3 dot operator ... works like the 2 dot operator .. except that the right operand isn't tested until the next evaluation.

--
John.