生成全字符随机的字串:
cat /dev/urandom | strings -n C | head -n L
生成数字加字母的随机字串:
cat /dev/urandom | sed ‘s/[^a-zA-Z0-9]//g‘ | strings -n C | head -n L
其中C表示字符串的字符数,L表示要生成多少行字符。
cat /dev/urandom |head -n 1 |md5sum |head -c L
[root@localhost ~]# cat /dev/urandom |head -1 |md5sum |head -c 10
70935c53ac
原文:http://feilong0663.blog.51cto.com/3265903/1357391