Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate random numbers between 0 and 1 in bash

Tags:

bash

shell

random

I'm trying to infer how to generate two random numbers as input values for parameters of readproportion, updateproportion in a way that sum of these parameters should equal 1, in the following bash command.

$ ./bin/ycsb run basic -P workloads/workloada -p readproportion=0.50 -p updateproportion=0.50

Please help with your suggestions.

Thanks

like image 360
encodeflush Avatar asked Dec 07 '25 08:12

encodeflush


1 Answers

As far as I can remember ${RANDOM} generates integers in the interval 0 - 32767. So, I guess, you might want to try something like this to generate random values in [0,1]:

bc -l <<< "scale=4 ; ${RANDOM}/32767"
like image 141
mauro Avatar answered Dec 08 '25 22:12

mauro