Skip to content

Instantly share code, notes, and snippets.

@visualdensity
Forked from markusfisch/uuid.sh
Last active April 29, 2017 12:19
Show Gist options
  • Save visualdensity/b0003f232840d4ea5ff1dc16f50ab8fe to your computer and use it in GitHub Desktop.
Save visualdensity/b0003f232840d4ea5ff1dc16f50ab8fe to your computer and use it in GitHub Desktop.
Generate a random UUID in bash and looped 30k times to generate more random bytes
#!/usr/bin/env bash
# Generate a pseudo UUID
uuid()
{
local N B C='89ab'
for (( N=0; N < 16; ++N ))
do
B=$(( $RANDOM%256 ))
case $N in
6)
printf '4%x' $(( B%16 ))
;;
8)
printf '%c%x' ${C:$RANDOM%${#C}:1} $(( B%16 ))
;;
3 | 5 | 7 | 9)
printf '%02x-' $B
;;
*)
printf '%02x' $B
;;
esac
done
echo
}
for i in {1..30000};
do
uuid
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment