delete all lines matching between two patterns in unix
eg: File contains the following
aaaaaa
aaaaa
bbbbbb
XYZ anajsksodo
argckl
wegcckl ZZZZZ
asdfg
qwett
zxcvv
I want to delete all lines where 1st character matches => XYZ and all the remaining lines until last character is => ZZZZZ
IT should return following O/P
aaaaaa
aaaaa
bbbbbb
asdfg
qwett
zxcvv
Tried below, line with XYZ is still getting printed, pls help !
perl -pe ‘s/^(XYZ).*?ZZZZZ/$1/ms’
Tried below, line with XYZ is still getting printed, pls help !
perl -pe ‘s/^(XYZ).*?ZZZZZ/$1/ms’