[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Grep para pegar as linhas de cima
From: |
jimmy |
Subject: |
Re: [shell-script] Grep para pegar as linhas de cima |
Date: |
Fri, 12 Sep 2008 11:30:52 -0300 |
User-agent: |
Mutt/1.4.2.3i |
confusa sua pergunta.
tenta isso daqui:
sed '/\(<operation>\|<target>\|<starttime>\|<fullResult>\|<status>\)/!d;
H;
/<status>/!d;
x;
s/\n//g;
s/<[^>]\+>/ /g;
s/^[ \t]\+//g;
/RESP:0/!d;' arquivo_de_1G
On Fri, Sep 12, 2008 at 01:46:12AM -0000, leo_caranguejeira wrote:
> Olá Pessoal,
>
> Estou me matando na solução de uma pesquisa com grep já faz um tempo.
> Gostaria de uma ajudinha, e desde já agradeço aos grandes
> conhecedores de sheell desta lista.
>
>
> Tenho um arquivo com o formato abaixo, de 1 G, o que eu preciso é
> grepar a linha "<status>" com o o resultado Resp:0 e pegar também as
> linhas "<operation>, <target> e <starttime> acima do status, o grep
> destas linhas forma um único comando.
> Resumindo, o grep do "<status>" mais as linhas acima forma um único
> comando, quero contar a quantidade de comandos com "<status>" Resp:0
> que estão aparecendo para cada comando.
>
> Bem, agradeço se alguém pode me ajudar.
>
> <log logid="82a9678d190809032359420284">
> <category>Upstream.CAI</category>
> <operation>Set</operation>
> <target>MHLRSUB</target>
> <instance>hlrSub.msisdn=551112345678</instance>
> <user>opsc_2</user>
> <context>sog.Oper_Create</context>
> <fullOperation>SET:HLRSUB:MSISDN,551112345678:CAMEL,SET,OCTDP,2,SK,2,C
> CH,2:CAMEL,SET,TCTDP,12,SK,4,CCH,2;</fullOperation>
> <starttime>20080903235942.784165</starttime>
> <stoptime>20080903235943.379073</stoptime>
> <fullResult>RESP:0;</fullResult>
> <status>SUCCESSFUL</status>
> </log>
> <log logid="82a9678d190809032359430288">
> <category>Upstream.CAI</category>
> <operation>Login</operation>
> <target>CAI</target>
> <instance></instance>
> <user>opsc_2</user>
> <context>sog.Oper_Create</context>
> <fullOperation>LOGIN:opsc_2:**********;</fullOperation>
> <starttime>20080903235943.392448</starttime>
> <stoptime>20080903235943.392662</stoptime>
> <fullResult>RESP:5000;</fullResult>
> <status>SUCCESSFUL</status>
> </log>
> <log logid="82a9678d190809032359430289">
> <category>Upstream.CAI</category>
> <operation></operation>
> <target>CAI</target>
> <instance></instance>
> <user>opsc_2</user>
> <context>sog.Oper_Create</context>
> <fullOperation>;</fullOperation>
> <starttime>20080903235943.463563</starttime>
> <stoptime>20080903235943.463855</stoptime>
> <fullResult>RESP:3001;Syntax Error;</fullResult>
> <status>FAILED</status>
> </log>
>
>
>
> ------------------------------------
>
> ---------------------------------------------------------------------
> Esta lista não admite a abordagem de outras liguagens de programação, como
> perl, C etc. Quem insistir em não seguir esta regra será moderado sem prévio
> aviso.
> ---------------------------------------------------------------------
> Sair da lista: address@hidden
> ---------------------------------------------------------------------
> Esta lista é moderada de acordo com o previsto em
> http://www.listas-discussao.cjb.net
> ---------------------------------------------------------------------
> Servidor Newsgroup da lista: news.gmane.org
> Grupo: gmane.org.user-groups.programming.shell.brazil
>
> Links do Yahoo! Grupos
>
_______________________________________________________________________________