I am trying to use Perl one liner, for matching a multi line pattern. My file "new" will look like something below.
foo
bar
foo1
bar1
go
bye
bar2
Intention is to match first four lines, which is between foo and bar1.
My one liner is given below:
perl -0777 -n -e 'm/^foo.+?bar1/s && print' new
I am reading the file as a whole instead of line by line using -0777. Also, I have given /s modifier for making "." match a "\n" also. But this one liner is not serving the purpose. It is matching the enitre file here.
I may be missing something very fundamental here. Can I have the help of experts on this, as this is something really annoying me for so long?