Last active
February 15, 2022 15:22
-
-
Save pythonhacker/95117153f84c98cff57f9bfdb7e11456 to your computer and use it in GitHub Desktop.
A pure bash function for creating UUIDs with no dependencies
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
function uuidgen() { | |
chunks=(4 2 2 2 6) | |
elems=() | |
for c in ${chunks[@]}; do | |
hex_chunk=$(xxd -l $c -p /dev/urandom) | |
elems+=( $hex_chunk ) | |
done | |
uuid=$(IFS=-, ;echo "${elems[*]}") | |
echo $uuid | |
} | |
uuidgen |
Author
pythonhacker
commented
Feb 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment