shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dividir arquivo em 02 colunas iguais


From: nerobarrabas
Subject: Re: Dividir arquivo em 02 colunas iguais
Date: Fri, 09 Nov 2012 11:25:03 -0000
User-agent: eGroups-EW/0.82

Maravilha Elder!
Que aula!
E já que é professor, vou abusar:
Não entendi como você conseguiu retirar todo o cabeçalho com apenas aqueles 
comandos do sed.
Por exemplo: qual o comando que eu deveria dar prá incluir a descrição do link 
que tem no cabeçalho e ficar assim:

Link '0' on board '0'
Changes to lock   6
Lost of signal   22
Alarm notification   0
Lost of frame   8
Lost of multiframe   13
Remote alarm   3
Slip alarm   1
PRBS   0
Wrong bits   0
Jitter variation   0
Frames without sync   0
Multiframe Signal   0
Frame error   39
Bipolar violation   78
CRC4 error   0

Valeu.

Diramos


--- Em address@hidden, Elder Marco <eldermarco@...> escreveu
>
> A minha abordagem foi utilizar o awk para pegar os campos e o sed para
> apagar o cabeçalho e o espaço
> no começo da linha, ficando assim:
> 
> $ cat raw.txt
> [0;37;40m<K> ----------------------------------------------------------
> <K> |------------------- Khomp Errors Counters on Links -----------------|
> <K> |----------------------------------------------------------|
> <K> |----- Link '0' on board '0' -----||----- Link '1' on board '0' -----|
> <K> |---------------------------------||---------------------------------|
> <K> | Error type | Number || Error type | Number |
> <K> |---------------------------------||---------------------------------|
> <K> | Changes to lock | 6 || Changes to lock | 10 |
> <K> | Lost of signal | 22 || Lost of signal | 53 |
> <K> | Alarm notification | 0 || Alarm notification | 0 |
> <K> | Lost of frame | 8 || Lost of frame | 46 |
> <K> | Lost of multiframe | 13 || Lost of multiframe | 55 |
> <K> | Remote alarm | 3 || Remote alarm | 16 |
> <K> | Slip alarm | 1 || Slip alarm | 616 |
> <K> | PRBS | 0 || PRBS | 0 |
> <K> | Wrong bits | 0 || Wrong bits | 0 |
> <K> | Jitter variation | 0 || Jitter variation | 0 |
> <K> | Frames without sync | 0 || Frames without sync | 0 |
> <K> | Multiframe Signal | 0 || Multiframe Signal | 0 |
> <K> | Frame error | 39 || Frame error | 112 |
> <K> | Bipolar violation | 78 || Bipolar violation | 18616 |
> <K> | CRC4 error | 0 || CRC4 error | 0 |
> <K> ----------------------------------------------------------
> [0m
> 
> $ awk -F'|' '/^<K> \| / { print $2, $3 }' raw.txt | sed '1d; s/^ //g'
> Changes to lock   6
> Lost of signal   22
> Alarm notification   0
> Lost of frame   8
> Lost of multiframe   13
> Remote alarm   3
> Slip alarm   1
> PRBS   0
> Wrong bits   0
> Jitter variation   0
> Frames without sync   0
> Multiframe Signal   0
> Frame error   39
> Bipolar violation   78
> CRC4 error   0
> 
> Neste caso, seria necessário apenas trocar os campos impressos com o awk.
> -- 
> Elder Marco
> 
> GNU/Linux User: #471180
> 
> "Contra o positivismo, que pára perante os fenômenos e diz: 'Há apenas
> fatos', eu digo: 'Ao contrário, fatos é o que não há; há apenas
> interpretações'. "(Nietzsche)
> 
> 
> [As partes desta mensagem que não continham texto foram removidas]
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]