'How to generate random even number as parameter of function in bash one line command?
I need to set random even number as function parameter in terminal:soapy_power -b random_even_number
First step, I generate random number with shuf -i1-10 -n1
Next,I try to judge whether random number is even,if not +1 to this number.
What I tried and failed:
$(((shuf -i1-10 -n1) %2 -eq 0 OR (shuf -i1-10 -n1)+1))
How to generate random even number as parameter of function in bash one line command?
Solution 1:[1]
Try
soapy_power -b "$(( RANDOM%5*2+2 ))"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
