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

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

Re: [shell-script] Somar números de um arquivo


From: Raul Libório
Subject: Re: [shell-script] Somar números de um arquivo
Date: Mon, 22 Aug 2016 14:28:24 -0300

Carlos Peixoto, usando a mesma lógica que o Júlio colocou no desafio anterior, respondo o seu:

$ cat file.txt
1.23 sdfa
4.55vvvv
sfgweg9.23
sdfgs 4.78 gh

$ echo "scale=3; $(sed 's/[Aa-zZ]//g;s/ //g' file.txt | tr '\n' '+') 0" | bc
19.79


Abraços

Raul Libório
http://rauhmaru.blogspot.com/
openSUSE Member | Linux User #4444581

/etc/httpd/conf.d/ssl.conf:7
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.

2016-08-22 13:31 GMT-03:00 Carlos Peixoto Costa Peixoto address@hidden [shell-script] <address@hidden>:
 

Tenho um arquivo com números reais, sendo somente um por linha. Como faço para extrair o total?

Ex:
1.23 sdfa
4.55vvvv
sfgweg9.23
sdfgs 4.78 gh

Grato a todos



reply via email to

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