Reputation: 13
I'd be glad if someone could tell me what the following lines should look like under linux bin/bash script:
rand1=%RANDOM%
rand2=%rand1:~1,2%
if %rand2% LSS 10 rand2=%rand2%+10
set /a macc6=%rand2%
Don't even know if there is even an equivalent to %RANDOM% to start with...
Upvotes: 1
Views: 372
Reputation: 246837
bash has $RANDOM
(Bash variables)
The step-by-step translation:
rand1=$RANDOM
rand2=$((rand1 % 100))
(( rand2 < 10 )) && (( rand2 += 10 ))
export macc6=$rand2
Without the temp variables:
export macc6=$(( RANDOM % 100 ))
(( macc6 < 10 )) && (( macc6 += 10 ))
Upvotes: 1