Advertisement
Juancho79

Bash function to generate a UUID v3

Jul 28th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.23 KB | None | 0 0
  1. # http://en.wikipedia.org/wiki/Universally_unique_identifier#Version_3_.28MD5_hash.29
  2. getUUID (){
  3.   a='89ab'
  4.   b=${a:$(($RANDOM%4)):1}
  5.   date +%s%N|md5sum -|sed -r "s/^(.{8})(.{4})(.)(.{3})(.)(.{3})(.{12})(.*$)/\1-\2-y\4-$b\6-\7/"
  6. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement