Extrair informações de arquivos de texto [RESOLVIDO]

1. Extrair informações de arquivos de texto [RESOLVIDO]

Sergio Fragoso
srsf88

(usa Ubuntu)

Enviado em 14/11/2013 - 15:10h

Ola !
Galera eu tinha um arquivo gerado pelos tomcats, que tinha cada um pelo menos umas 700 linhas apos executar alguns comandos conseguir reduzir ele a um saída com 7 linhas exatamente dos serviços que estão rodando neles :

Exemplo do arquivo obtido:

worker.balancerXXXZ.balance_workers=tomcat1sist,tomcat1sist2,tomcat1sist3,tomcat1sist4,tomcat1sist5,tomcat1sist6
worker.balancerXXXZY.balance_workers=tomcat0sist4,tomcat14sist
worker.balancerXXXZYY.balance_workers=tomcat3sist6,tomcat3sist8,tomcat5sist,tomcat5sist2,tomcat5sist3,tomcat5sist4,tomcat5sist5,tomcat5sist6$
worker.balancerXXXZYYW.balance_workers=tomcat13sist,tomcat13sist2,tomcat13sist3,tomcat13sist4,tomcat13sist5,tomcat13sist7
worker.balancerXXZW.balance_workers=tomcat0sist2,tomcat0sist3,tomcat2sist,tomcat2sist2,tomcat2sist3,tomcat3sist2,tomcat3sist3,tomcat3sist4$
worker.balancerXZWE.balance_workers=tomcat3sist7,tomcat3sist9,tomcat15sist,tomcat15sist2,tomcat15sist3,tomcat15sist4,tomcat15sist5,
worker.balancerXRE.balance_workers=tomcat3sist,tomcat3sist5

Bom abaixo segue um exemplo da saída que esperada para estes arquivos, como pode ver eles estão organizados em colunas e nao estou conseguindo deixa eles assim
Exemplo de saída:

tomcat0.xxxx.br sist2 XXZW sistXXZW
tomcat0.xxxx.br sist3 XXZW sistXXZW
tomcat2.xxxx.br sist XXZW sistXXZW
tomcat2.xxxx.br sist2 XXZW sistXXZW
tomcat2.xxxx.br sist3 XXZW sistXXZW
tomcat3.xxxx.br sist2 XXZW sistXXZW
tomcat3.xxxx.br sist3 XXZW sistXXZW
tomcat3.xxxx.br sist4 XXZW sistXXZW
tomcat4.xxxx.br sist2 XXZW sistXXZW
tomcat4.xxxx.br sist3 XXZW sistXXZW
tomcat4.xxxx.br sist4 XXZW sistXXZW
tomcat6.xxxx.br sist XXZW sistXXZW
tomcat6.xxxx.br sist2 XXZW sistXXZW
tomcat7.xxxx.br sist2 XXZW sistXXZW
tomcat7.xxxx.br sist3 XXZW sistXXZW
tomcat7.xxxx.br sist4 XXZW sistXXZW
tomcat12.xxxx.br sist XXZW sistXXZW
tomcat12.xxxx.br sist2 XXZW sistXXZW
tomcat14.xxxx.br sist2 XXZW sistXXZW
tomcat3.xxxx.br sist sistXRE sistXRE
tomcat3.xxxx.br sist5 sistXRE sistXRE
tomcat3.xxxx.br sist6 XXXZYYa sistXXXZYY
tomcat3.xxxx.br sist8 XXXZYY sistXXXZYY
tomcat5.xxxx.br sist XXXZYY sistXXXZYY
tomcat5.xxxx.br sist2 XXXZYY sistXXXZYY
tomcat5.xxxx.br sist3 XXXZYY sistXXXZYY
tomcat5.xxxx.br sist4 XXXZYY sistXXXZYY
tomcat5.xxxx.br sist5 XXXZYY sistXXXZYY
tomcat5.xxxx.br sist6 XXXZYY sistXXXZYY
tomcat5.xxxx.br sist7 XXXZYY sistXXXZYY
tomcat12.xxxx.br sist4 XXXZYY sistXXXZYY
tomcat13.xxxx.br sist6 XXXZYY sistXXXZYY
tomcat13.xxxx.br sist sistXRE sistXREX
tomcat13.xxxx.br sist2 sistXRE sistXREX
tomcat13.xxxx.br sist3 sistXRE sistXREX
tomcat13.xxxx.br sist4 sistXRE sistXREX
tomcat13.xxxx.br sist5 sistXRE sistXREX
tomcat13.xxxx.br sist7 sistXRE sistXREX
tomcat1.xxxx.br sist XXXZ sistXXXZ
tomcat1.xxxx.br sist2 XXXZ sistXXXZ
tomcat1.xxxx.br sist3 XXXZ sistXXXZ
tomcat1.xxxx.br sist4 XXXZ sistXXXZ
tomcat1.xxxx.br sist5 XXXZ sistXXXZ
tomcat1.xxxx.br sist6 XXXZ sistXXXZ
tomcat3.xxxx.br sist7 XZWE sistXZWE
tomcat3.xxxx.br sist9 XZWE sistXZWE
tomcat15.xxxx.br sist XZWE sistXZWE
tomcat15.xxxx.br sist2 XZWE sistXZWE
tomcat15.xxxx.br sist3 XZWE sistXZWE
tomcat15.xxxx.br sist4 XZWE sistXZWE
tomcat15.xxxx.br sist5 XZWE sistXZWE
tomcat15.xxxx.br sist6 XZWE sistXZWE
tomcat15.xxxx.br sist7 XZWE sistXZWE
tomcat15.xxxx.br sist8 XZWE sistXZWE
tomcat15.xxxx.br sist9 XZWE sistXZWE
tomcat0.xxxx.br sist4 XXXZYY sistXXXZYY
tomcat14.xxxx.br sist XXXZYY sistXXXZYY

Alguma sugestão de como obter esta saída padrão para um novo arquivo....




  


2. MELHOR RESPOSTA

Alexandre Gonçalves Monteiro da Silva
alexandregms

(usa Ubuntu)

Enviado em 18/11/2013 - 12:07h

Veja se da certo:


cat file.txt | cut -d= -f2 | sed 's/\,/\n/g' | awk -F"sist" '{print $1".xxxx.br sist" $2" XXZW sistXXZW"}'


3. Re: Extrair informações de arquivos de texto [RESOLVIDO]

Sergio Fragoso
srsf88

(usa Ubuntu)

Enviado em 18/11/2013 - 17:19h

Valeu Resolvido.






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts