Random tcsh from / dev / random and / dev / urandom

I am trying to figure out how to generate random use of / dev / random and / dev / urandom in tcsh. After I do head -c 1 / dev / random, I get a random byte. How to include this byte in the actual number?

+4
source share
3 answers
$ head -c 1 /dev/urandom | od -t u1 | cut -c9- 

This will give you a random integer from 0 to 255 inclusive.

+8
source

My apologies for redirecting your question in advance, but although it is not used for your script, bash may be convenient here if you have one:

 bash -c 'echo $RANDOM' 

will return a random integer. Therefore you can use:

 RANDOM=`bash -c 'echo $RANDOM'` 

from tcsh script to achieve the same variable.

+6
source

this works in csh OS X -> it will generate 1 number between 2 and 10 and assign it to random:

 set random = `jot -r 1 2 10` echo "random number $random was generated" 
0
source

Source: https://habr.com/ru/post/1333023/


All Articles