The UNIX and Linux Forums  


Go Back   O UNIX e Linux Forum > Top Fóruns > Programação Shell Script e
.
google unix.com



Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui.

Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
Fio Thread Starter Fórum Respostas Última postagem
pesquisa ") com egrep - egrep: erro de sintaxe sagarjani UNIX para Dummies Perguntas & Respostas 7 10-14-2008 08:30
egrep / grep resultado de mais arquivos tvrman Programação Shell Script e 3 08-07-2008 09:29
Egrep batota folha em algum lugar? Olhando para o significado do egrep-c leelm UNIX para Dummies Perguntas & Respostas 2 01-11-2008 03:37
Perl - copiar arquivos BG_JrAdmin Programação Shell Script e 1 12-13-2007 09:50
Perl fazer o upload de arquivos sstevens UNIX & avançada para usuários experientes 16 02-24-2004 03:03

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
Linkback Thread Tools Pesquisar este Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-17-2008
thepurple thepurple is offline
Usuário
  
 

Join Date: Oct 2007
Lugares: 134
Perl ou awk, egrep de grandes arquivos?

Oi peritos.

Em uma discussão Já perguntei-lhe como grep a seqüência do arquivo abaixo -

Infelizmente, o script não deu bom resultado (ele perdeu muitas cordas). Foi o que aconteceu pode ser eu te dei o bom conteúdo do arquivo

Esse foi o script -
"$ perl -00nle 'print join "\ n", / <fullOperation> (.*?):.*< fullResult >(.*?);/ s' filename.txt"

Agora para você convinience i cole conteúdo aqui desde o início do arquivo -

Saída do arquivo abaixo seria -

CREATE
RESP: -3010

DELETE
RESP: 0

CREATE
RESP: 911364896

GET
RESP: 0

SET
RESP: 911265678


<? xml version \u003d'1 .0 'encoding \u003d "ISO-8859-1' standalone \u003d 'não'?>
<LogItems>
<log logid\u003d"83efeae5190811100759420954">
<category> Upstream.CAI </ categoria>
<operation> Login </ operation>
<target> CAI </ meta>
<Instance> </ exemplo>
<user> </ usuário>
<Context> </ contexto>
<fullOperation> LOGIN: servidor1: eri4ema </ fullOperation>
<starttime> 20081110075942,366900 </ STARTTIME>
<stoptime> 20081110075942,424451 </ stoptime>
<fullResult> RESP: 3001; </ fullResult>
<Status> FRACASSAMOS </ status>
</ log>
<log logid\u003d"83efeae5190811100759480955">
<category> Upstream.CAI </ categoria>
<operation> Login </ operation>
<target> CAI </ meta>
<Instance> </ exemplo>
<user> </ usuário>
<Context> </ contexto>
<fullOperation> LOGIN: servidor1: eri4ema; </ fullOperation>
<starttime> 20081110075948,375669 </ STARTTIME>
<stoptime> 20081110075948,375923 </ stoptime>
<fullResult> RESP: 3007; </ fullResult>
<Status> FRACASSAMOS </ status>
</ log>
<log logid\u003d"83efeae5190811100759580956">
<category> Upstream.CAI </ categoria>
<operation> Login </ operation>
<target> CAI </ meta>
<Instance> </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> LOGIN: servidor1 :*******;</ fullOperation>
<starttime> 20081110075958,354986 </ STARTTIME>
<stoptime> 20081110075958,355238 </ stoptime>
<fullResult> RESP: 0; </ fullResult>
<Status> ÊXITO </ status>
</ log>
</ LogItems>

<? xml version \u003d'1 .0 'encoding \u003d "ISO-8859-1' standalone \u003d 'não'?>
<LogItems>
<log logid\u003d"83efeae5190811100802020957">
<category> Upstream.CAI </ categoria>
Receba <operation> </ operation>
<target> ESUB </ meta>
CÓDIGO <Instance> \u003d 432350114484630 </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> GET: ESUB: CODE, 432350114484630; </ fullOperation>
<starttime> 20081110080202,185236 </ STARTTIME>
<stoptime> 20081110080202,834500 </ stoptime>
<fullResult> RESP: 11000003; UNKNOWN assinante; </ fullResult>
<Status> FRACASSAMOS </ status>
</ log>
</ LogItems>

<? xml version \u003d'1 .0 'encoding \u003d "ISO-8859-1' standalone \u003d 'não'?>
<LogItems>
<log logid\u003d"83efeae5190811100802120958">
<category> Upstream.CAI </ categoria>
Receba <operation> </ operation>
<target> DSUB </ meta>
<Instance> </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> GETSUB: MDN, 989352375449; </ fullOperation>
<starttime> 20081110080212,352053 </ STARTTIME>
<stoptime> 20081110080213,376720 </ stoptime>
<fullResult> RESP: 0: MDN, 989352375449: CODE, 432350114484630: PAÍS, FI: LANG, fi: PRE, 0: SUBNAME, Eserve: MMS, 1; </ fullResult>
<Status> ÊXITO </ status>
</ log>
</ LogItems>

<? xml version \u003d'1 .0 'encoding \u003d "ISO-8859-1' standalone \u003d 'não'?>
<LogItems>
<log logid\u003d"83efeae5190811100802350959">
<category> Upstream.CAI </ categoria>
Receba <operation> </ operation>
<target> ACCOUNTINFORMATION </ meta>
<Instance> </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> GET: ACCOUNTINFORMATION: SubscriberNumber, 989352375449; </ fullOperation>
<starttime> 20081110080235,264165 </ STARTTIME>
<stoptime> 20081110080235,555880 </ stoptime>
<fullResult> RESP: -3010; </ fullResult>
<Status> FRACASSAMOS </ status>
</ log>
<log logid\u003d"83efeae5190811100802450960">
<category> Upstream.CAI </ categoria>
<operation> Excluir </ operation>
<target> EDSUB </ meta>
<Instance> </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> DELETE: EDSUB: CODE, 432350114484630: MDN, 989352375449: PRE, 0EST, ALL; </ fullOperation>
<starttime> 20081110080245,012208 </ STARTTIME>
<stoptime> 20081110080245,857994 </ stoptime>
<fullResult> RESP: 0; </ fullResult>
<Status> ÊXITO </ status>
</ log>
<log logid\u003d"83efeae5190811100802510961">
<category> Upstream.CAI </ categoria>
<operation> Crie </ operation>
<target> EDSUB </ meta>
<Instance> </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> CREATE: EDSUB: CODE, 432350114484630: KI, 1C9B39AAF3931D60C064F6E8FBB5B1E6: MDN, 98935237544 9: PRE, 0EST, ALL; </ fullOperation>
<starttime> 20081110080251,089898 </ STARTTIME>
<stoptime> 20081110080251,489396 </ stoptime>
<fullResult> RESP: 911364896; </ fullResult>
<Status> FRACASSAMOS </ status>
</ log>
<log logid\u003d"83efeae5190811100802540962">
<category> Upstream.CAI </ categoria>
Receba <operation> </ operation>
<target> ESUB </ meta>
CÓDIGO <Instance> \u003d 432350114484630 </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> GET: ESUB: CODE, 432350114484630; </ fullOperation>
<starttime> 20081110080254,000313 </ STARTTIME>
<stoptime> 20081110080254,697545 </ stoptime>
<fullResult> RESP: 0: MDN, 989352375449: CODE, 432350114484630: T11, 1: T21, 1: T22, 1: B16, 1: T62, 1: BAIC, 0: BAOC, 0: BOIC, 0: Biro, 0 : Boro, 0: BOIH, 0: BOS4, 0: CLIP, 1: CLIR, 0: CFB, 1: CFNR, 1: CFNA, 1: CFU, 1: HOLD, 1: CW, 1: MPTY, 1: BAICS , 0,0: BAOCS, 0,0: BOICS, 0,0: PRE, 0; </ fullResult>
<Status> ÊXITO </ status>
</ log>
<log logid\u003d"83efeae5190811100802570963">
<category> Upstream.CAI </ categoria>
<operation> Set </ operation>
<target> DSUB </ meta>
<Instance> </ exemplo>
<user> servidor1 </ usuário>
<Context> sog </ contexto>
<fullOperation> SETSUB: MDN, 989352375449; </ fullOperation>
<starttime> 20081110080257,888204 </ STARTTIME>
<stoptime> 20081110080257,999121 </ stoptime>
<fullResult> RESP: 911265678; </ fullResult>
<Status> FRACASSAMOS </ status>
</ log>
</ LogItems>
  #2 (permalink)  
Old 11-17-2008
thepurple thepurple is offline
Usuário
  
 

Join Date: Oct 2007
Lugares: 134
Eu executar comandos abaixo. Mas não serei uma boa saída. No entanto, ele tem 3 minutos para 35MB arquivo. Mas tenho 900MB arquivo

egrep '<fullOperation> DELETE | <fullOperation> SET | <fullOperation> CREATE | <fullOperation> GET | <fullResult> RESP'

Saída foi -

<fullOperation> GET: ESUB: MDN, 989371072136; </ fullOperation>
<fullResult> RESP: 0: MDN, 989371072136: CODE, 432350022011344: LastName, 989371072136: PrimeiroNome ,2008-11-08_16_10: PAÍS, IR: LANG, fa: PRÉ, 1: SUBNAME, Eserve: MMS, 0; </ fullResult >
<fullResult> RESP: 0; </ fullResult>
<fullResult> RESP: 0; </ fullResult> -> Resp: vem duas vezes


A produção deve ser -
GET
Resp: 0
  #3 (permalink)  
Old 11-17-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
viciado
  
 

Join Date: Jan 2007
Localização: Варна, България / Milano, Italia
Mensagens: 2.910
Sim,
a amostra de dados no anterior ameaça foi diferente (eu estava assumindo tags separados por branco (vazia) linhas).
Tente este:

Código:
perl -nle'BEGIN {$/="</log>";$,="\n";$\="\n\n"}
  print /<fullOperation>(.*?):.*<fullResult>(.*?:.*?)[:;]/s
  ' infile
  #4 (permalink)  
Old 11-17-2008
thepurple thepurple is offline
Usuário
  
 

Join Date: Oct 2007
Lugares: 134
Oaoo Greate seu trabalho. Quero colocar a saída em arquivos.

Encontrei-o como abaixo. Mas output.txt contém algumas cordas que não é compensada com a produção original na minha tela

perl -NLE 'BEGIN {$/\u003d"</ log >";$,\u003d" \ n "; $ \ \u003d" \ n \ n ") print / <fullOperation> (.*?):.*< fullResult> ( .*?:.*?)[:;]/ s "2008-11-11.0.log > Output.txt
  #5 (permalink)  
Old 11-17-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
viciado
  
 

Join Date: Jan 2007
Localização: Варна, България / Milano, Italia
Mensagens: 2.910
Isso é estranho, você poderia postar um exemplo dessas cordas?
  #6 (permalink)  
Old 11-17-2008
thepurple thepurple is offline
Usuário
  
 

Join Date: Oct 2007
Lugares: 134
Opss Eu realmente sinto muito amigo .. Funcionou. Na verdade eu coloquei o nome errado.

Enfim, espero que me possa colocar "N" número de ficheiros com o perl script.

perl -NLE 'BEGIN {$/\u003d"</ log >";$,\u003d" \ n "; $ \ \u003d" \ n \ n ") print / <fullOperation> (.*?):.*< fullResult> ( .*?:.*?)[:;]/ s' logfile1 logflie2 ... logfileN
  #7 (permalink)  
Old 11-17-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
viciado
  
 

Join Date: Jan 2007
Localização: Варна, България / Milano, Italia
Mensagens: 2.910
Você pode.
Closed Thread

Marcadores

Thread Tools Pesquisar este Thread
Pesquisar este Thread:

Pesquisa Avançada
Display Modes Esta taxa Thread
Esta taxa Thread:

Destacamento Regimento
Você não pode postar novas threads
Você não pode postar respostas
Você não pode postar anexos
Você não pode editar suas postagens

BB code é Ligado
Smilies são Ligado
[IMG] código é Ligado
Código HTML é Desligado
Trackbacks são Ligado
Pingbacks são Ligado
Refbacks são Ligado




Todos os horários são GMT -4. A hora é agora 09:38.


Powered by: vBulletinCopyright © 2000 - 2006, Jelsoft Enterprises Limited. Língua Traduções Powered by .
vBCredits v1.4 Copyright © 2007 - 2008, PixelFX Studios
O UNIX e Linux Fóruns Content Copyright © 1993-2009. Todos os Direitos Reserved.Ad Gestão por RedTyger

Content Relevant URLs por vBSEO 3.2.0