Precisa anexar ao restante da linha entre cada tag

0

Eu tenho um arquivo como este:

<LocationMatch ^/raframework>
SetHandler weblogic-handler
WeblogicCluster xlytwv02-pub.sherwin.com:45330
WLIOTimeoutSecs 6000
Idempotent OFF
</LocationMatch>

<LocationMatch ^/biplus_webservices>
SetHandler weblogic-handler
WeblogicCluster xlytwv02-pub.sherwin.com:45330
</LocationMatch>

<LocationMatch ^/hr>
SetHandler weblogic-handler
WeblogicCluster xlytwv02-pub.sherwin.com:8530
WLIOTimeoutSecs 18000
Idempotent OFF
WLSocketTimeoutSecs 18000
</LocationMatch>

Eu preciso modificá-lo para que pareça: qualquer valor

  <LocationMatch ^/raframework>
  raframework:SetHandler weblogic-handler
  raframework:WeblogicCluster xlytwv02-pub.sherwin.com:45330
  raframework:WLIOTimeoutSecs 6000
  raframework:Idempotent OFF
  </LocationMatch>

  <LocationMatch ^/biplus_webservices>
  biplus_webservices:SetHandler weblogic-handler
  biplus_webservices:WeblogicCluster xlytwv02-pub.sherwin.com:45330
  </LocationMatch>

  <LocationMatch ^/hr>
  hr:SetHandler weblogic-handler
  hr:WeblogicCluster xlytwv02-pub.sherwin.com:8530
  hr:WLIOTimeoutSecs 18000
  hr:Idempotent OFF
  hr:WLSocketTimeoutSecs 18000
  </LocationMatch>
    
por Naresh 09.09.2016 / 22:24

1 resposta

1

Um filtro awk que rastreia os valores <LocationMatch.../> e os prefixos das linhas intermediárias deve funcionar:

awk '/^<LocationMatch \^/ {
  print $0
  m=substr($2,3,length($2)-3) ":"
  next
}
/^<\/LocationMatch>/ { m="" }
{ print m $0 }
'

Nesse loop m é o prefixo (incluindo o : ). Nós o definimos no <LocationMatch> e o desmarcamos nas linhas </LocationMatch> . Quaisquer linhas fora delas (incluindo linhas em branco e quaisquer linhas antes / depois) devem ser deixadas intactas.

    
por 09.09.2016 / 23:26