linux uuid
2016-03-28 00:00
417 查看
一、uuid 生成
See theuuidgenprogram which is part of the e2fsprogs package.
According to this,
libuuidis now part of util-linux and the inclusion in e2fsprogs is being phased out.
(On new Ubuntu systems,
uuidgenis now in the
uuid-runtimepackage.)
To create a uuid and save it in a variable:
uuid=$(uuidgen)
On my Ubuntu system, the alpha characters are output as lower case and on my OS X system, they are output as upper case (thanks to David for pointing this out in a comment).
To switch to all upper case (after generating it as above):
uuid=${uuid^^}
To switch to all lower case:
uuid=${uuid,,}
If, for example, you have two UUIDs and you want to compare them in Bash, ignoring their case, you can do a
tolower()style comparison like this:
if [[ ${uuid1,,} == ${uuid2,,} ]]
2、减少对Linux依赖性的用法
To add variety without adding external dependencies, on Linux you can do:UUID=$(cat /proc/sys/kernel/random/uuid)
To propagate bad practices, on FreeBSD, under the linux compatibility layer (linuxulator?),
UUID=$(cat /compat/linux/proc/sys/kernel/random/uuid)
References:
UUID on Wikipedia.
FreeBSD Bug #186187 - [linprocfs] [patch] emulate /proc/sys/kernel/random/uuid
相关文章推荐
- Linux socket 初步
- Linux Kernel 4.0 RC5 发布!
- linux lsof详解
- linux 文件权限
- Linux 执行数学运算
- 10 篇对初学者和专家都有用的 Linux 命令教程
- Linux 与 Windows 对UNICODE 的处理方式
- Ubuntu12.04下QQ完美走起啊!走起啊!有木有啊!
- 解決Linux下Android开发真机调试设备不被识别问题
- 运维入门
- 运维提升
- Linux 自检和 SystemTap
- Ubuntu Linux使用体验
- c语言实现hashmap(转载)
- Linux 信号signal处理机制
- linux下mysql添加用户
- Scientific Linux 5.5 图形安装教程
- Linux 下无损图片压缩小工具介绍