[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] Somando uma fatura com o awk
From: |
Flavio Junior |
Subject: |
Re: [shell-script] Somando uma fatura com o awk |
Date: |
Fri, 4 Jan 2008 10:19:44 -0200 |
$ awk 'BEGIN { total=0 }; { total = total + $3}; END{ print total }' fatura.txt
Tenta isso.. A ideia é essa.. talvez um erro de ; q eu nao testei
--
Flávio do Carmo Júnior
On Jan 4, 2008 10:13 AM, voyeg3r <address@hidden> wrote:
>
>
>
>
>
>
> Eu tenho uma fatura assim:
>
> Obs: substitui espaços no campo 2 por _
>
> 12/01/2007 INSINUANTE_LJ_187(12/12) 187,91
> 04/09/2007 RABELO_SOM_E_IMAGEM(04/12) 51,75
> 03/11/2007 EXTRA_1375_PARANGABA(03/04) 41,75
> 03/11/2007 EXTRA_1375_PARANGABA(03/04) 11,75
> 13/11/2007 INTUICAO(02/02) 34,50
> 21/11/2007 ADAUTO_PECAS(02/06) 200,00
> 17/12/2007 ANUIDADE(12/12) 7,00
> 26/12/2007 VIACAO_ITAPEMIRIM(01/03) 259,34
>
> awk '{ total = total + $3; print total}' fatura.txt
>
> Resultado:
> 187,91
> 239,66
> 281,41
> 293,16
> 327,66
> 527,66
> 534,66
> 794
>
> queria uma versão do comando que imprimisse somente a última linha,
> ou seja, o total :)
>
>