Incrementing a variable by 0.025 for each loop in BASH (NOT loop variable) -


i wanted increment variable, k inside loop. each increment 0.025. tried using:

let "k += 0.025"

and

let "$k += 0.025"

and

k += 0.025

and many other variations. know how accomplish this?

use integer math , convert decimal when needed.

#!/bin/bash  k=25  # start of loop #    # increment variable 0.025 (times 1000).   #   let k="$k+25"    # value fraction (uses bc).   #   v=$(echo "$k/1000"|bc -l)  # end of loop #     echo $v 

save t.sh, then:

$ chmod +x t.sh $ ./t.sh  .05000000000000000000 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -