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

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

Re: [shell-script] Somando uma fatura com o awk


From: miranda
Subject: Re: [shell-script] Somando uma fatura com o awk
Date: Fri, 04 Jan 2008 10:28:55 -0300

[miranda@guitar local]$ cat fatura
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 'BEGIN{S=0}{S+=$3}END{print "Total: " S}' fatura
Total: 790


On Fri, 2008-01-04 at 12:13 +0000, voyeg3r 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 :)
> 
> 
> 
> 
>  



reply via email to

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