I am trying to extract data between 2 matching patterns, only if the content is not empty and I have issues doing it:
here is an example:
==============================
Queue Manager is : MQ73PCRTB2
==============================
==============================
Queue Manager is : MQ73PCSH01
==============================
_________________________________
Current instances are over 80% of max instnaces allowed for the channel WAS.P2QG2E00.SVRC
Max Instances allowed is 100
Current Instances running is 100
==============================
Queue Manager is : MQ73PCSH02
==============================
_________________________________
Current instances are over 80% of max instnaces allowed for the channel WAS.P2QG2E00.SVRC
Max Instances allowed is 100
Current Instances running is 100
==============================
Queue Manager is : MQ73PCSHA1
==============================
==============================
Queue Manager is : MQ73PCSHA2
==============================
What I want to see in output is:
==============================
Queue Manager is : MQ73PCSH01
==============================
_________________________________
Current instances are over 80% of max instnaces allowed for the channel WAS.P2QG2E00.SVRC
Max Instances allowed is 100
Current Instances running is 100
==============================
Queue Manager is : MQ73PCSH02
==============================
_________________________________
Current instances are over 80% of max instnaces allowed for the channel WAS.P2QG2E00.SVRC
Max Instances allowed is 100
Current Instances running is 100
I know I to extract lines before and after matching text , extract everything between matching patterns, but want to know how to print everything between matching pattern only if the data is not empty.
Here is what i tried and didn't work:
grep -zPo '(?s)Queue(?:.(?!</Queue))*?\Current*?</Queue'
The original text file is generated by another script.
There could be more than 3 lines in data between the matching pattern 'Queue'