Created
December 11, 2018 17:40
-
-
Save MurphysChaos/918215434044f0473b3f5ca82a0b599f to your computer and use it in GitHub Desktop.
Generate a random GUID/UUID
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# 1. Get 16 characters (128 bits) from a pseudorandom number generator | |
# 2. Convert characters to hexadecimal representation | |
# 3. Remove spaces from string | |
# 4. Insert dashes | |
echo $(head -c 16 /dev/urandom | od -t x8 -An | sed 's/ //g' | sed -E 's/(.{8})(.{4})(.{4})(.{4})(.{12})/\1-\2-\3-\4-\5/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment