Search code examples
bashloopsdecimalweka

Loop in bash from 0.01 to 0.5


I am creating a script in bash to call a command 100 times, varying a float parameter each time. I need to call it with 0.01, then 0.02, 0.03 up to 0.5. As I cannot create a loop using a float in the condition or in the step I am not sure of how to do it. I tried doing the loop from 1 to 50 and then inside dividing the number by 100, transforming that into a float, and calling the command with that, but then the command (basically I am calling Weka and the number corresponds to the confidence interval) doesn't recognize the parameter correctly so maybe I am using the wrong datatype.

Thanks in advance! Patricio


Solution

  • for i in `seq 0.01 0.01 0.5`; do  echo "called with $i" ; done
    

    this will create a seq of 0.01 to 0.5 in increment of 0.01. So replace the echo with your needed call.