How to generate a random decimal number from 0 to 3 with bash?
问题 I want to generate a random decimal number from 0 to 3, the result should look like this: 0.2 1.5 2.9 The only command I know is: echo "0.$(( ($RANDOM%500) + 500))" but this always generates 0.xxx . How do I do that ? 回答1: Bash has no support for non-integers. The snippet you have just generates a random number between 500 and 999 and then prints it after "0." to make it look like a real number. There are lots of ways to do something similar in bash (generating the integer and decimal parts