[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how to generate random negative numbers



user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -26: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -3: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -23: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -2: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -29: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -19: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -13: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -30: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -21: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -14: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -1: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -7: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -26: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -26: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -25: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -5: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -5: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -29: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -3: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -16: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -29: command not found
user@debian:~$ $[ ($RANDOM % 30 ) -30 ]
bash: -18: command not found
user@debian:~$ 

it still doesn't work, and it gives only negative numbers when using e.g.: 30....-30
but thank you:)
I'm still searching:P

On Wed, Aug 12, 2009 at 1:52 PM, Alan Chandler <alan@chandlerfamily.org.uk> wrote:
Soren Orel wrote:
I know I could generate numbers like: 0; 1; 2
with:
$[ ( $RANDOM % 3 ) + 0 ]
But how could I generate numbers like: 0; 1; 2; -1; -2; etc? So negative+positive numbers too + zero
thank you

$[ ($RANDOM % 5 ) -2 ]

?

(I have no idea if I have the bash syntax right)

--
Alan Chandler
http://www.chandlerfamily.org.uk


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org



Reply to: