randomtcsh

tcsh random number from /dev/random and /dev/urandom


I am trying to figure out how to generate random from using /dev/random and /dev/urandom in tcsh. After I do head -c 1 /dev/random, I get a random byte. How do I turn this byte into actual number?


Solution

  • $ head -c 1 /dev/urandom | od -t u1 | cut -c9-
    

    That will give you a random integer between 0 and 255 inclusive.