Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- random() {
- local n x
- if [ $1 -le 0 ]; then
- echo 0
- return
- fi
- if [ $1 -lt 255 ]; then
- n=1
- elif [ $1 -lt 65535 ]; then
- n=2
- else
- n=4
- fi
- x='0x'$(dd if=/dev/urandom bs=$n count=1 2>/dev/null | xxd -ps)
- echo $((x % $1))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement