1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| awk '
/<property>/ { i++ }
/toto/ { x=1 }
/<\/property>/ {
i--
b=sprintf("%s%s",b,$0)
if(i==0 && x!=1) print b
b=""
x=0
next
}
{
if(i==0) print
else b=sprintf("%s%s\n",b,$0)
}
' fichier.xml
<list>
<property>
<untruc>titi</untruc>
<autrestrucs>
....
</autrestrucs>
</property>
<property>
<untruc>toto</untruc>
<autrestrucs>
....
</autrestrucs>
</property>
<property>
<untruc>tata</untruc>
<autrestrucs>
....
</autrestrucs>
</property>
</list> |