sh 在bash中生成UUID4的便携方法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 在bash中生成UUID4的便携方法相关的知识,希望对你有一定的参考价值。

uuid4() {
  first=`LC_ALL=C tr -dc a-f0-9 < /dev/urandom  |
    dd bs=8 count=1 2> /dev/null`
  second=`LC_ALL=C tr -dc a-f0-9 < /dev/urandom |
    dd bs=4 count=1 2> /dev/null`
  third=`LC_ALL=C tr -dc a-f0-9 < /dev/urandom  |
    dd bs=4 count=1 2> /dev/null`
  fourth=`LC_ALL=C tr -dc a-f0-9 < /dev/urandom |
    dd bs=12 count=1 2> /dev/null`
  printf "$first-$second-$third-$fourth"
}

以上是关于sh 在bash中生成UUID4的便携方法的主要内容,如果未能解决你的问题,请参考以下文章