perl - How can I sum up the exponent value in bash shell? -


here example values

2.31312e+06 4.34234234e+07 4.578362e+06 3.213124124e+06 

how can add them?

numbers args:

perl -le'$s += $_ @argv; end { print $s }' 

numbers on stdin or file named argument (one per line):

perl -nle'$s += $_; end { print $s }' 

use printf '%e\n', $s instead of print $s if want result in exponent notation.


Comments

Popular posts from this blog

rest - Spring boot: Request method 'PUT' not supported -

c++11 - Intel compiler and "cannot have an in-class initializer" when using constexpr -

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -