生成全字符随机的字串:
CODE
cat /dev/urandom | strings -n C | head -1
生成数字加字母的随机字串:
CODE
cat /dev/urandom | sed ’s/[^a-zA-Z0-9]//g’ | strings -n C | head -1
其中C表示字符串的字符数
如果您喜欢本文,欢迎订阅我的文章:
http://feed.jiayii.com
转载请注明出处:http://www.jiayii.com/shell-generate-random-sting/
谢谢您的关注。 : @jiayisuse : jiayisuse#gmail.com
转载请注明出处:http://www.jiayii.com/shell-generate-random-sting/
谢谢您的关注。 : @jiayisuse : jiayisuse#gmail.com


研究过/dev/zero,研究过/dev/null,还真没研究过/dev/urandom。
这回学习了,不错的技巧!
[Reply]
这个参数有点意思,研究下
[Reply]