一段批量生成虚拟机MAC地址的shell脚本,使用方法 vmac.sh num

#!/bin/bash
export LANG=en_US.UTF-8
if [[ $1 != \'\' ]];then
NUM=$1
else
NUM=1
fi
mac() {
MACADDR="00:16:3E:$(dd if=/dev/urandom count=1 2>/dev/null | md5sum | sed \'s/^(..)(..)(..)(..).*$/1:2:3/\')"
echo $MACADDR|tr \'[a-z]\' \'[A-Z]\';
}
for ((i=1;i<=$NUM;i++)) do mac done

哟?不错哎 订阅小米的RSS Feeds 回去慢慢看^_^