Imprimir apenas uma vez linha com inicio repetido [RESOLVIDO]

1. Imprimir apenas uma vez linha com inicio repetido [RESOLVIDO]

Patrick Campos
patrickcampos

(usa Debian)

Enviado em 12/06/2017 - 17:38h

Tenho um arquivo que contem os dados abaixo, gostaria de imprimir somente um vez as linhas que tenham o mesmo horario.
com os dados que está no final da mensagem, um exemplo do que gosaria de imprimir seria:

09:52:18.992312 IP 192.168.59.217.rsh-spx > 192.168.59.29.slp:
09:52:24.584187 IP 192.168.59.217.rsh-spx > 192.168.59.29.slp:
09:52:32.914469 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:33.091209 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:34.120195 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:

Como poderia ser feito isto? abaixo os dados do arquivo:

09:52:18.992312 IP 192.168.59.217.rsh-spx > 192.168.59.29.slp:
09:52:18.992419 IP 192.168.59.29.slp > 192.168.59.217.rsh-spx:
09:52:18.992312 IP 192.168.59.217.rsh-spx > 192.168.59.29.slp:
09:52:24.584187 IP 192.168.59.217.rsh-spx > 192.168.59.29.slp:
09:52:32.914469 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:33.091209 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:33.091323 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:33.276201 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:33.276694 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:33.454194 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:33.457218 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:33.457230 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:33.457376 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:33.724417 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:33.943196 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:33.943290 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:34.120195 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:34.126804 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:34.214316 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:34.400510 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:34.489211 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:34.706201 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:39.369063 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:39.546204 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:39.546215 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:39.546422 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:39.763203 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.091213 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.091403 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:40.268200 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.450201 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.450430 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:40.627209 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.628195 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.628398 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:40.806206 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.806302 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:40.987204 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:40.987379 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.166204 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.167196 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.167284 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.204202 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.207209 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.207219 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.207293 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.208668 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.208678 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.208757 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.210202 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.210212 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.210288 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.212195 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.212278 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.345276 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.345289 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.345385 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:41.345424 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:41.512491 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:42.479533 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:42.656202 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:42.656295 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:42.833202 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:42.833295 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:43.012196 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:43.020209 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:43.020302 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:43.024197 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:43.214702 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:44.517212 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:44.707205 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:44.709197 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:44.709289 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:44.709404 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:44.716782 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:44.893200 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:44.893293 IP 192.168.59.29.netbill-auth > 52.201.95.63.ssh:
09:52:45.069201 IP 52.201.95.63.ssh > 192.168.59.29.netbill-auth:
09:52:52.219034 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.226206 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.226326 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.242199 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.242669 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.249199 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.251203 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.457209 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.457306 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.776205 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.823204 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.823296 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.830210 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.833206 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:52.920626 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:52.949227 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:53.037370 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:53.083199 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:54.545269 IP 192.168.59.29.slp > 192.168.59.217.rsh-spx:
09:52:54.545293 IP 192.168.59.217.rsh-spx > 192.168.59.29.slp:
09:52:56.104944 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.111201 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.111212 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.111437 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.119197 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.119357 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.165196 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.188200 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.188359 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.195194 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.197209 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.197386 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.243200 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.243282 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.251198 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.256199 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.256352 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.265203 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.265214 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:
09:52:56.265304 IP 192.168.59.29.netbill-prod > 200.146.92.154.ssh:
09:52:56.305201 IP 200.146.92.154.ssh > 192.168.59.29.netbill-prod:


  


2. MELHOR RESPOSTA

Marcelo Oliver
msoliver

(usa Debian)

Enviado em 12/06/2017 - 19:06h

Boa noite, para eliminar as linhas onde o horário é repetido, faça:
sort -n -t" " -k1 dados.txt|uniq 


Att.:
marcelo oliver

3. Re: Imprimir apenas uma vez linha com inicio repetido [RESOLVIDO]

Patrick Campos
patrickcampos

(usa Debian)

Enviado em 13/06/2017 - 08:48h

msoliver escreveu:

Boa noite, para eliminar as linhas onde o horário é repetido, faça:
sort -n -t" " -k1 dados.txt|uniq 


Att.:
marcelo oliver


Valeu Marcelo,

o comando não imprimiu da maneira que eu esperava ainda, porém lendo o man do uniq descobri o -w, que compara somente um numero determinado de caractere da linha e assim deu certo, segue abaixo o código.

sort -n -t"." -k1 tcp.txt | uniq -w8 


o 8 representa quantos caracteres quero comparar. Valeu pela ajuda!






Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts