On Sat, 5 Oct 2002, Peter Leftwich wrote:

> I was sorting through my /usr/X11R6/bin/startx text-file and noticed:
 >
> mcookie=`dd if=/dev/urandom bs=16 count=1 2>/dev/null | hexdump -e \\"%08x\\"`
>
> I started playing around with `cat /dev/urandom` and `head -1 /dev/urandom`
> so my question is... How can I use the head -1 method and change the output
> into just [A-Za-z0-9] and no spaces or punctuation?  And specify length?

Why head -1...? /dev/random isn't very line oriented.  Oh, well,
nevermind.  One way of doing what you want is:

 tr -cd a-zA-Z0-9 < /dev/urandom | dd bs=$len count=1 2>/dev/null

Which will give you $len random bytes from the set a-zA-Z0-9 (it reads
a lot more from /dev/urandom than it produces though).

Another answer is, as always, "use perl" :-)

  $.02,
  /Mikko


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to