刚好用到, mark一下:
#! /bin/bash tb_base=tb_student_ arr=("0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f") GetCmd() { for value in ${arr[@]} do for value2 in ${arr[@]} do tb_name=$tb_base$value$value2 cmd="ALTER TABLE ${tb_name} ADD INDEX seed (uid,name); " echo $cmd done done } GetCmd $1上面的结果就是要执行的语句, done.
嗯,tb_student_和"tb_student_"都可以