From: Brendan on
Hello,

An oft-repeated means for seeding bash $RANDOM is:
RANDOM=$$$(date +%s)

However on Linux 2.6.18-xen #1 SMP Fri May 18 16:11:33 BST 2007 i686
GNU/Linux thise method is not working for me:
RANDOM=$$$(date +%s)
echo $RANDOM

I keep getting a value of 15929. Why is the seed value invalid? 32-bit
OS?

Thanks

From: mop2 on
On Sun, 31 Jan 2010 14:33:32 -0200, Brendan <brendandetracey(a)yahoo.com> wrote:

> Hello,
>
> An oft-repeated means for seeding bash $RANDOM is:
> RANDOM=$$$(date +%s)
>
> However on Linux 2.6.18-xen #1 SMP Fri May 18 16:11:33 BST 2007 i686
> GNU/Linux thise method is not working for me:
> RANDOM=$$$(date +%s)
> echo $RANDOM
>
> I keep getting a value of 15929. Why is the seed value invalid? 32-bit
> OS?
>
> Thanks
>
>

RANDOM is a special var.

Try:
unset RANDOM
RANDOM=$(date +%s)
From: Jon LaBadie on
mop2 wrote:
> On Sun, 31 Jan 2010 14:33:32 -0200, Brendan <brendandetracey(a)yahoo.com>
> wrote:
>
>> Hello,
>>
>> An oft-repeated means for seeding bash $RANDOM is:
>> RANDOM=$$$(date +%s)
>>
>> However on Linux 2.6.18-xen #1 SMP Fri May 18 16:11:33 BST 2007 i686
>> GNU/Linux thise method is not working for me:
>> RANDOM=$$$(date +%s)
>> echo $RANDOM
>>
>> I keep getting a value of 15929. Why is the seed value invalid? 32-bit
>> OS?
>>
>> Thanks
>>
>>
>
> RANDOM is a special var.
>
> Try:
> unset RANDOM
> RANDOM=$(date +%s)

You should have tried it yourself.

unsetting RANDOM takes away its "specialness".
From: mop2 on
On Sun, 31 Jan 2010 15:38:33 -0200, Jon LaBadie <jlabadie(a)axcxm.org> wrote:

> mop2 wrote:
>> On Sun, 31 Jan 2010 14:33:32 -0200, Brendan <brendandetracey(a)yahoo.com>
>> wrote:
>>
>>> Hello,
>>>
>>> An oft-repeated means for seeding bash $RANDOM is:
>>> RANDOM=$$$(date +%s)
>>>
>>> However on Linux 2.6.18-xen #1 SMP Fri May 18 16:11:33 BST 2007 i686
>>> GNU/Linux thise method is not working for me:
>>> RANDOM=$$$(date +%s)
>>> echo $RANDOM
>>>
>>> I keep getting a value of 15929. Why is the seed value invalid? 32-bit
>>> OS?
>>>
>>> Thanks
>>>
>>>
>>
>> RANDOM is a special var.
>>
>> Try:
>> unset RANDOM
>> RANDOM=$(date +%s)
>
> You should have tried it yourself.
>
> unsetting RANDOM takes away its "specialness".

Is not this exactly what the OP wants?
From: Jon LaBadie on
Brendan wrote:
> Hello,
>
> An oft-repeated means for seeding bash $RANDOM is:
> RANDOM=$$$(date +%s)
>
> However on Linux 2.6.18-xen #1 SMP Fri May 18 16:11:33 BST 2007 i686
> GNU/Linux thise method is not working for me:
> RANDOM=$$$(date +%s)
> echo $RANDOM
>
> I keep getting a value of 15929. Why is the seed value invalid? 32-bit
> OS?
>
> Thanks
>
Looks like it only takes the current PID $$ which happen to be 5 digits
and below 32767, the max value for $RANDOM.

Try to get your seed in the range 0 - 32767 with something like this:

RANDOM=$(( ( $(date +%s) + $$ ) % 32768 ))