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

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

Re: [shell-script] Formatar texto


From: Rodrigo Monteiro
Subject: Re: [shell-script] Formatar texto
Date: Fri, 4 Nov 2005 13:22:15 -0300

Olá Mauricy,

On 11/1/05, Mauricy Maiorino <address@hidden> wrote:
> Pessoal
>
> Como posso formatar um arquivo do tipo:
>
> anabelon 674 ifch
> andrade 203 ic
> andreasp 71 ifch
> zec             1 gh
>
>
>
> Para:
>
> anabelon    |    674    |    ifch
> andrade      |    203    |       ic
> andreasp    |       71   |    ifch
> zec              |         1   |      gh
>
> (Porém alinhado, é que escrevendo "na mão" fica assim !!)
>
> Obrigado!!
>
> Mauricy
>

root@sepsrv123:/tmp/tmp# cat teste.txt
anabelon 674 ifch
andrade 203 ic
andreasp 71 ifch
zec             1 gh
root@sepsrv123:/tmp/tmp# awk '{print $1"\t"$2"\t"$3}' teste.txt
anabelon        674     ifch
andrade 203     ic
andreasp        71      ifch
zec     1       gh
root@sepsrv123:/tmp/tmp# awk '{print $1"\t"$2"\t"$3}' teste.txt > saida.txt
root@sepsrv123:/tmp/tmp# cat -vet saida.txt
anabelon^I674^Iifch$
andrade^I203^Iic$
andreasp^I71^Iifch$
zec^I1^Igh$
root@sepsrv123:/tmp/tmp#

Como vc pode ver com o cat -vet ele ficou com um tab entre as
palavras. Agora é só alterar e deixar do jeito que vc quiser.

root@sepsrv123:/tmp/tmp# awk '{print $1"\t|\t"$2"\t|\t"$3}' teste.txt
anabelon        |       674     |       ifch
andrade |       203     |       ic
andreasp        |       71      |       ifch
zec     |       1       |       gh
root@sepsrv123:/tmp/tmp# awk '{print $1"\t|\t"$2"\t|\t"$3}' teste.txt | cat -vet
anabelon^I|^I674^I|^Iifch$
andrade^I|^I203^I|^Iic$
andreasp^I|^I71^I|^Iifch$
zec^I|^I1^I|^Igh$
root@sepsrv123:/tmp/tmp#


Espero ter ajudado.
[]s


--
"Free as in Freedom, not free as in free beer"
Rodrigo Monteiro
JID: address@hidden
address@hidden


reply via email to

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