On Sat, Aug 09, 2003 at 05:07:08PM -0500, Bret Hughes wrote:
> I was able to dd the /dev/urandom but was lost how to turn all those
> funky chars into a number.

You are on a binary computer, and /dev/urandom is spitting out binary
data--what could be more fundamentally a number than that?

If you want some ACSII representation of your bits you need to decide
what kind of number you want: "Pick a number from one to ten.", double
precision between 0 and 1, integer from 0 to 255--the possibilities
are many.

I am not a shell scripting guru, but I can suggest the starting point
of using "od" (octal dump):

  $ head -c 2 /dev/random | od -v -i
  0000000  23557
  0000002
  $ head -c 4 /dev/random | od -v -l
  0000000  1766076095
  0000004
  $ head -c 4 /dev/random | od -f -v
  0000000   5.071397e+23
  0000004

In that output the first column is the "address" (od is intended to be
for examining files), so you need to find some od option to omit that
or filter it out later.  The first example is two bytes turned into a
signed 16-bit integer, the second is four bytes turned into a signed
32-bit integer, the third is four bytes turned into a single precision
floating point.

I am sure there is a better way to do this (a better tool than od?),
but that should get you started.


-kb


-- 
redhat-list mailing list
unsubscribe mailto:[EMAIL PROTECTED]
https://www.redhat.com/mailman/listinfo/redhat-list

Reply via email to