Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] random in bash [Kmail Notification]



On 8 Mar 2002, Stephen J. Turnbull wrote:

> If you're allowed to use tr(1), then head(1) should be OK?

Sure, but head is just going to look for \012 bytes in the stream -- does
that help?

> head -10 /dev/random \
>  | tr '\200-\377' '\000-\0177' \
>  | tr --delete '\000-\0377\177'

This is an interesting idea though.  How about this, to get 8 random
digits:

tr -d '\372-\377' < /dev/urandom | dd bs=8 count=1 conv=sync 2>/dev/null |
tr '\144-\307' '\000-\143' | tr '\310-\372' '\000-\143' |
tr '\062-\143' '\000-\061' | tr '\024-\047' '\000-\023' |
tr '\050-\061' '\000-\011' | tr '\012-\023' '\000-\011' |
tr '\000-\011' 0-9 ; echo
-- 
Tod McQuillin



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links