思路一:
echo $RANDOM|md5sum |tr "[0-9]" "[a-j]"|cut -c 2-11
RANDOM: linux内置的随机数变量 默认是5个
md5sum :使用MD5加密,变成随机的字母
tr :替换。把0-9 替换成a-j
cut :截取出2-11位
#!/bin/sh [ -d "./test" ] || mkdir -p ./test
for n in `seq `
do
touch ./test/$(echo $RANDOM|md5sum |tr "[0-9]" "[a-j]"|cut -c -)_oldboy.html
done
openssl rand 用于产生指定长度个bytes的随机字符。
-base64 / -hex 对随机字符串进行base64编码或用hex格式显示
#!/bin/sh
path=./test
[ -d "${path}" ] || mkdir -p ${path}
for n in `seq `
do random=$(openssl rand -base64 |sed 's#[^a-z]##g'|cut -c -)
touch ${path}/${random}_oldboy.html
done
openssl rand -base64 40 |sed 's#[^a-z]##g'