[root@local-centos7 ~]# cat round.sh #!/bin/bash count=1 while [ $count -le 50 ] do round=`cat /dev/urandom | head -n 10 | md5sum | head -c 8` echo $round >> /root/round.txt let count++ done 或者也可以这样来写 for((i=1;i<=50;i++)); do head -n 10 /dev/urandom| md5sum | head -c 8|sed -nr 's#.*#&\n#pg'|tee -a file &>/dev/null ; done </dev/urandom tr -dc 'a-zA-Z0-9!@#$%^&*()_+' | head -c 15