vendredi 2 décembre 2016

print text between 2 pattern when find a match inside

for one of my script i need to print text between 2 pattern when a match if found inside, i dont find how to make it simple.

the content of the file is:

===== seble dom0 report =====
IP address: 10.42.0.100
location: slot-3.enclosure-43.eqx
ID: infra-dom0.dom0.seble
Xen-Version: 4.4
CPU: Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz

===== arnica dom0 report =====
IP address: 10.1.42.46
location: slot-3.enclosure-12.eqx
ID: infra-dom0.dom0-3
Xen-Version: 4.1
CPU: AMD Opteron(tm) Processor 6174

===== sithtemd dom0 report =====
IP address: 10.1.42.191
location: slot-13.enclosure-7.vty
ID: infra-dom0.mutu119
Xen-Version: 4.4
CPU: Intel(R) Xeon(R) CPU X5670 @ 2.93GHz

if i seach enclosure-7 for exemple i would like it return :

===== sithtemd dom0 report =====
IP address: 10.1.42.191
location: slot-13.enclosure-7.vty
ID: infra-dom0.mutu119
Xen-Version: 4.4
CPU: Intel(R) Xeon(R) CPU X5670 @ 2.93GHz

It's a mix between a grep and a sed -n "/===== /,/^$/p" but can't find it...

Thanks in advance for your answers :)

Aucun commentaire:

Enregistrer un commentaire