unix - Add floating numbers in bash -


I'm trying a little bit easier, but I'm trying to make sure that all the code does not work. Float numbers have to be added. I am doing this:

  result1 = `$ curl -o / dev / null -s -w% {time_total} $ url1` result 2 =` $ curl -o / dev / null - S -w% {time_total} $ url2` result3 = `$ curl -o / dev / null -s -w% {time_total} $ url3` total = 'exproded $ result2 + $ result3` transcribe $ total | $ GAWK -F: '{print} connection_1.value "$ 1}'  

But I'm getting this output:

  ./ Http_response_2 : Line 12: 0,018 + 0255: Command not found connection.name  

I also try to do this:

  result1 = `$ curl - O / dev / null -s -w% {time_total} $ url1` result2 = `curl -o / dev / null -s -w% {time_total} $ url2` result 3 =` curl -o / dev / Null - S -w% {time_total} $ url3` total = `result2 + $ result3 | BC`  

Thanks in advance to get the same result!

There are 3 problems:

  1. Should total = & Amp;
  2. $ result2 + $ result3
  3. There is a comma in your input instead of the missing echo, decimal input

Fix all these problems:

  total = $ (tr ',' '.' & Lt; & lt; <"$ result2 + $ result3" | BC -L)  

If you are worried about the key 0 before the decimal point, then try:

  total = $ (tr ',' '' & Lt; & Lt; & Lt; "$ Result2 + $ result3" | BC-L | Excerpt printf "% g")  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -